using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DBUtility; using SQLHelper; namespace LMES { public partial class Frm_Show : Form { public Frm_Show() { InitializeComponent(); } public OAM.OA_WorkLinkBill oFrm; private void ClearTool() { cg.CheckState = CheckState.Unchecked; xs.CheckState = CheckState.Unchecked; kf.CheckState = CheckState.Unchecked; jh.CheckState = CheckState.Unchecked; sc.CheckState = CheckState.Unchecked; cj.CheckState = CheckState.Unchecked; oa.CheckState = CheckState.Unchecked; tx.CheckState = CheckState.Unchecked; gy.CheckState = CheckState.Unchecked; xt.CheckState = CheckState.Unchecked; oa.CheckState = CheckState.Unchecked; mj.CheckState = CheckState.Unchecked; Zp.CheckState = CheckState.Unchecked; sb.CheckState = CheckState.Unchecked; pz.CheckState = CheckState.Unchecked; sup.CheckState = CheckState.Unchecked; pay.CheckState = CheckState.Unchecked; } private void SetTool(ToolStripButton oBr) { oBr.CheckState = CheckState.Checked; //显示子项目 grdList.Rows.Clear(); DataSet oDs; Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper(); oDs = oCn.RunProcReturn("select * from xt_xtgnb where sjgnbm='" + oBr.Name + "' and menulist=1 Order by gnbm", "xt_xtgnb"); if (oDs == null || oDs.Tables[0].Rows.Count == 0) { return; } for (int i = 0; i < oDs.Tables[0].Rows.Count; i++) { grdList.Rows.Add(); grdList.Rows[i].Cells["NameCol"].Value = oDs.Tables[0].Rows[i]["gnmc"].ToString(); grdList.Rows[i].Cells["IDCol"].Value = oDs.Tables[0].Rows[i]["gnbm"].ToString(); //如果未购买则显示灰色 if (DBUtility.ClsPub.isBool(oDs.Tables[0].Rows[i]["buyFlag"]) != true) { grdList.Rows[i].DefaultCellStyle.ForeColor = Color.LightGray; } else { grdList.Rows[i].DefaultCellStyle.ForeColor = Color.Black; } // } //默认将第一项目 显示出 下级项目 if (oDs.Tables[0].Rows.Count >= 0) { ShowSubItems(0); } } //设置主菜单 private void ShowMainMenu() { InitTool(); } private void SetPic() { //Image img = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/MainToolPic.jpg"); ; //panel3.BackgroundImage = img; } private void Frm_Show_Load(object sender, EventArgs e) { SetPic(); ClearTool(); //SetTool(cg); //设置主菜单 ShowMainMenu(); //设置当前用户和企业 SetUserName(); // ShowMsg(); } private void SetUserName() { lblAccountName.Text = "本机IP:" + DBUtility.ClsPub.IPAddress; lblUserName.Text = "Windows用户:" + DBUtility.ClsPub.ComputerName; lblDate.Text = BLL.ClsDateToNongli.GetChineseDateTime(DateTime.Today); } private void grdList_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { e.Handled = true; e.PaintBackground(e.CellBounds, true); e.PaintContent(e.CellBounds); } private void grdSub_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { e.Handled = true; e.PaintBackground(e.CellBounds, true); e.PaintContent(e.CellBounds); } private void ShowSubItems(int sRow) { grdSub.Rows.Clear(); DataSet oDs; Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper(); oDs = oCn.RunProcReturn("select * from xt_xtgnb where sjgnbm='" + grdList.Rows[sRow].Cells["IDCol"].Value + "' and menulist=1 Order by gnbm", "xt_xtgnb"); if (oDs == null || oDs.Tables[0].Rows.Count == 0) { return; } for (int i = 0; i < oDs.Tables[0].Rows.Count; i++) { grdSub.Rows.Add(); grdSub.Rows[i].Cells["SubNameCol"].Value = oDs.Tables[0].Rows[i]["gnmc"].ToString(); grdSub.Rows[i].Cells["SubNumberCol"].Value = oDs.Tables[0].Rows[i]["gnsy"].ToString(); grdSub.Rows[i].Cells["SubIDCol"].Value = oDs.Tables[0].Rows[i]["gnbm"].ToString(); //如果未购买则显示灰色 if (DBUtility.ClsPub.isBool(oDs.Tables[0].Rows[i]["buyFlag"]) != true) { grdSub.Rows[i].DefaultCellStyle.ForeColor = Color.LightGray; } else { grdSub.Rows[i].DefaultCellStyle.ForeColor = Color.Black; } // } } private void grdList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (grdList.CurrentCell == null) { return; } ShowSubItems(grdList.CurrentCell.RowIndex); } private void grdSub_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (grdSub.CurrentCell == null) { return; } //判断颜色 if (grdSub.Rows[grdSub.CurrentCell.RowIndex].DefaultCellStyle.ForeColor == Color.LightGray) { MessageBox.Show("对不起,您尚未购买本模块,请求不被允许!"); return; } // string gnmc = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells["SubNameCol"].Value.ToString(); string gnsy = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells["SubNumberCol"].Value.ToString(); string gnbm = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells["SubIDCol"].Value.ToString(); ClsShowMod oMod = new ClsShowMod(); oMod.Zxxymk(gnsy.ToLower().Trim(), gnbm.ToLower().Trim(),gnmc.Trim() ,this.MdiParent); } private void ShowMsg() { DataSet oDs; Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper(); oDs = oCn.RunProcReturn("h_p_OA_EmpMinMessageList " + DBUtility.ClsPub.CurUserName.ToString(), "xt_xtgnb"); if (oDs != null) { grdList1.DataSource = oDs.Tables[0].DefaultView; //grdList2.DataSource = oDs.Tables[0].DefaultView; grdList1.Columns[0].Visible = false; grdList1.Columns[1].Visible = false; } // oDs = oCn.RunProcReturn("exec h_p_OA_WorkBillList " + DBUtility.ClsPub.CurUserName.ToString(), "xt_xtgnb"); if (oDs == null) { return; } grdList2.DataSource = oDs.Tables[0].DefaultView; grdList2.Columns[0].Visible = false; grdList2.Columns[1].Visible = false; // DBUtility.ClsPub.GetGridView(this.grdList1, this.Name + "grdList1", DBUtility.ClsPub.AppPath); DBUtility.ClsPub.GetGridView(this.grdList2, this.Name + "grdList2", DBUtility.ClsPub.AppPath); } private void Frm_Show_FormClosing(object sender, FormClosingEventArgs e) { DBUtility.ClsPub.SaveGridView(this.grdList1, this.Name + "grdList1", DBUtility.ClsPub.AppPath); DBUtility.ClsPub.SaveGridView(this.grdList2, this.Name + "grdList2", DBUtility.ClsPub.AppPath); } // private Int32 Fun_GetCol(string sCol) { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList2); } //双击显示grdList1 private void grdList1_DoubleClick(object sender, EventArgs e) { //Int64 lngBillKey = 0; //if (grdList1.CurrentRow == null) // return; //lngBillKey = DBUtility.ClsPub.isLong(grdList1.Rows[grdList1.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value); //if (lngBillKey == 0) // return; //DAL.ClsOA_EmpMinMessage oBill = new DAL.ClsOA_EmpMinMessage(); //if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //{ // oFrm = new OAM.OA_EmpMinMessage(); // oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; // oFrm.BillOld = oBill; // oFrm.ShowDialog(); //} } //双击显示grdList2 private void grdList2_DoubleClick(object sender, EventArgs e) { Int64 lngBillKey = 0; if (grdList2.CurrentRow == null) return; lngBillKey = DBUtility.ClsPub.isLong(grdList2.Rows[grdList2.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value); if (lngBillKey == 0) return; DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { oFrm = new OAM.OA_WorkLinkBill(); oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; oFrm.BillOld = oBill; oFrm.ShowDialog(); } } private void gy_Click(object sender, EventArgs e) { ClearTool(); SetTool(gy); } private void cg_Click(object sender, EventArgs e) { ClearTool(); SetTool(cg); } private void xs_Click(object sender, EventArgs e) { ClearTool(); SetTool(xs); } private void ck_Click(object sender, EventArgs e) { ClearTool(); SetTool(kf); } private void jh_Click(object sender, EventArgs e) { ClearTool(); SetTool(jh); } private void sc_Click(object sender, EventArgs e) { ClearTool(); SetTool(sc); } private void cj_Click(object sender, EventArgs e) { ClearTool(); SetTool(cj); } private void tx_Click(object sender, EventArgs e) { ClearTool(); SetTool(tx); } private void xt_Click(object sender, EventArgs e) { ClearTool(); SetTool(xt); } private void oa_Click(object sender, EventArgs e) { ClearTool(); SetTool(oa); } ClsCN oCn = new ClsCN(); public const int MaxNum = 100; public int NowNum = 0; private void timer1_Tick(object sender, EventArgs e) { if (NowNum > MaxNum) { NowNum = 0; FindCheckBill(); } else { NowNum++; } } //查询待审核单据 private void FindCheckBill() { try { DataSet ds; ds = oCn.RunProcReturn("exec h_p_Xt_GetNeedMessageList '" + ClsPub.CurUserName + "'", "xt_xtgnb"); if (ds == null || ds.Tables[0].Rows.Count == 0) { return; } else { ShowMessage(ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]), ds.Tables[0].Rows[0]["单据号"].ToString(), ds.Tables[0].Rows[0]["单据类型"].ToString(), ds.Tables[0].Rows[0]["单据类型名称"].ToString()); } } catch (Exception e) { return; } } //显示消息框 private void ShowMessage(Int64 HInterID, string HBillNo, string HBillType, string HBillTypeName) { OA_MessageBox oBox = new OA_MessageBox(); int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 300; int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - 230; oBox.SetDesktopLocation(x, y); oBox.HInterID = HInterID; oBox.HBillNo = HBillNo; oBox.HBillType = HBillType; oBox.HBillTypeName = HBillTypeName; timer1.Enabled = false; oBox.ShowDialog(); timer1.Enabled = true; } public void InitTool() { ClsCN ocn = new ClsCN(); DataSet ds = new DataSet(); string sh = ""; ds = ocn.RunProcReturn("select hname from Xt_MainMenuSet where HShowFlag=0", "Xt_MainMenuSet"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { sh = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["hname"]); Sub_HideButton(this.toolStrip2, sh); } } //隐藏按钮 public void Sub_HideButton(ToolStrip otool, string sName) { foreach (object ct in otool.Items) { if (ct.GetType().Name == "ToolStripButton") { if (((System.Windows.Forms.ToolStripButton)ct).Tag.ToString().Trim() == sName) { ((System.Windows.Forms.ToolStripButton)ct).Visible = false; } } if (ct.GetType().Name == "ToolStripSeparator") { if (((System.Windows.Forms.ToolStripSeparator)ct).Tag.ToString().Trim() == sName) { ((System.Windows.Forms.ToolStripSeparator)ct).Visible = false; } } } } private void kq_Click(object sender, EventArgs e) { ClearTool(); SetTool(mj); } private void pct_Click(object sender, EventArgs e) { ClearTool(); SetTool(Zp); } private void lblMore2_Click(object sender, EventArgs e) { //morebt oMo = new morebt(); //oMo.Huoqu(1); //oMo.ShowDialog(); } private void lblMore_Click(object sender, EventArgs e) { //morebt oMo = new morebt(); //oMo.Huoqu(0); //oMo.ShowDialog(); } private void sb_Click(object sender, EventArgs e) { ClearTool(); SetTool(sb); } private void pz_Click(object sender, EventArgs e) { ClearTool(); SetTool(pz); } private void sup_Click(object sender, EventArgs e) { ClearTool(); SetTool(sup); } private void pBarCodeEdit_Click(object sender, EventArgs e) { WarM.Sc_ICMOToBarCode oSc_ICMOToBarCode = new WarM.Sc_ICMOToBarCode(); oSc_ICMOToBarCode.ModCaption = "条码快速生成"; oSc_ICMOToBarCode.ShowDialog(); } private void pay_Click(object sender, EventArgs e) { ClearTool(); SetTool(pay); } } }