using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Pub_Class; namespace OAM { public partial class frm_txl1 : Form { public int FitemID; public string Fnumber; public string Fname; public string Tel; public string InnerTel; public string Mobile; public string Email; public string Virtual; public string FRemark; private int HItemIDCol = 0; private int HNumberCol = 0; TreeNode CurNode = new TreeNode(); public node_add1 onode_add1 = new node_add1(); public frm_add1 ofrm_add1 = new frm_add1(); public DBUtility.ClsPub.Enum_InputMode InputMode; //¼Èë״̬±êÖ¾(0-·Ç¼Èë״̬ 1-Ôö¼Ó 2-ÐÞ¸Ä) public frm_txl1() { InitializeComponent(); } //ÏÔʾÁбí private void Display() // »ÃÐÄ { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; //sSql = "Select * from h_v_EmployeeConList order by ͨѶ¼´úÂë"; string oDeptid = CurNode.Name.Replace("T", ""); if (oDeptid == "") { oDeptid = "Deptid"; } if (CurNode.Text == "ͨѶ¼") { sSql = "Select * from h_v_EmployeeConList where 1=1 order by ͨѶ¼´úÂë"; DSet = SubCn.RunProcReturn(sSql, "h_v_EmployeeConList", ref DBUtility.ClsPub.sExeReturnInfo); // if (DSet == null) { MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo); return; } grdMain.DataSource = DSet.Tables[0].DefaultView; DBUtility.Gy_BaseFun.DisplayGrid(grdMain, this.Name); return; } sSql = "Select * from h_v_EmployeeConList where Deptid=" +oDeptid + " order by ͨѶ¼´úÂë"; //Ö´ÐÐSQL DSet = SubCn.RunProcReturn(sSql,"h_v_EmployeeConList", ref DBUtility.ClsPub.sExeReturnInfo); // if (DSet == null) { MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo); return; } grdMain.DataSource = DSet.Tables[0].DefaultView; DBUtility.Gy_BaseFun.DisplayGrid(grdMain, this.Name); // } private void Gy_Department_Load(object sender, EventArgs e) { LoadTree(TreeView, imageList1, this.Text); RefreshTool(); } //public static void initGrid(DataGridView grdMain) //{ // grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //Ñ¡ÖÐģʽ--ÐÐÑ¡ÖÐ // grdMain.ColumnHeadersVisible = true; //±êÌâÁÐÏÔʾ--ÊÇ // grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //±êÌâÁгߴçģʽ--£¨×Ô¶¯µ÷Õû£¬¿Éµ÷Õû£© // grdMain.RowTemplate.Height = 18; // grdMain.RowTemplate.MinimumHeight = 18; // grdMain.ColumnHeadersHeight = 35; //±êÌâÐÐ¸ß // grdMain.RowHeadersVisible = false; //±êÌâÐпɼû--·ñ // grdMain.AllowUserToAddRows = false; //ÊÇ·ñÔÊÐí×ÔÔö--·ñ // grdMain.AllowUserToDeleteRows = false; //ÊÇ·ñÔÊÐíɾ³ý--·ñ // grdMain.ColumnCount = 0; //×ÜÁÐÊý--5 // grdMain.RowCount = 0; // grdMain.AllowUserToResizeColumns = true; //ÔÊÐíµ÷ÕûÁпí--ÊÇ // grdMain.AllowUserToResizeRows = false; //ÔÊÐíµ÷ÕûÐиß--·ñ // grdMain.ReadOnly = true; //Ö»¶Á--ÊÇ // grdMain.BackgroundColor = Color.White; // grdMain.GridColor = Color.LightGray; // grdMain.DefaultCellStyle.SelectionBackColor = Color.Black; // grdMain.EnableHeadersVisualStyles = false; //Íø¸ñ±êÌâ Ñùʽ // grdMain.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGray; //} //Ë¢ÐÂTOOLBAR private void RefreshTool()//Lock { } //¼ÓÔØÊ÷ÐÎ public static void LoadTree(TreeView tv, ImageList imageList1, string Text)//Lock { try { tv.Nodes.Clear(); tv.ImageList = imageList1; TreeNode sNode = tv.Nodes.Add("T0", Text, 0, 1); LoadAllNodes(sNode); } catch (Exception e) { MessageBox.Show("¼ÓÔØÊ÷ÐÍʧ°Ü£¡" + e.Message, "Ìáʾ"); } } public static void LoadAllNodes(TreeNode sNode) //Lock { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (sNode != null) { try { //long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1)); sNode.Nodes.Clear(); //ofrm_add1.oDeptid = CurNode.Name.Replace("T", ""); DataSet Ds = oCn.RunProcReturn("select fitemid,Fnumber,Fname from deptlist order by Fnumber", "deptlist", ref ClsPub.sExeReturnInfo); for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { // Ds.Tables[0].Rows[i]["FileName"].ToString() + "-" + Ds.Tables[0].Rows[i]["HName"].ToString(), //if() TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["fitemid"].ToString(), Ds.Tables[0].Rows[i]["Fnumber"].ToString() + "-" + Ds.Tables[0].Rows[i]["Fname"].ToString(), 1, 1); } sNode.Expand(); } catch (Exception e) { MessageBox.Show("¼ÓÔØ×ÓÏîĿʧ°Ü£¡" + e.Message, "Ìáʾ"); } } } private void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { CurNode = e.Node; if (CurNode != null) { Display(); //if (CurNode.Nodes.Count == 0) // LoadAllNodes(CurNode); ////ÕÒµ½Ñ¡Öнáµã } } private void jz_Click(object sender, EventArgs e) { onode_add1.up_flag = true; onode_add1.ShowDialog(); LoadTree(TreeView, imageList1, this.Text); } private void gz_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); try { if (CurNode==null) { return; } string sid = CurNode.Name.Replace("T", ""); //²éѯ±í DataSet Ds; Ds = oCn.RunProcReturn("Select * from deptlist where fitemid='" + sid + "'", "deptlist"); if (Ds.Tables[0].Rows.Count == 0) { return; } //¸³Öµ node_add1 onode_add1 = new node_add1(); onode_add1.fitemid = Ds.Tables[0].Rows[0]["fitemid"].ToString().Trim(); onode_add1.Fnumber = Ds.Tables[0].Rows[0]["Fnumber"].ToString().Trim(); onode_add1.Fname = Ds.Tables[0].Rows[0]["Fname"].ToString().Trim(); onode_add1.ShowDialog(); LoadTree(TreeView, imageList1, this.Text); return; } catch (Exception e1) { return; } } //ÐÞ¸Ä private void Modify() { if (DBUtility.Gy_BaseFun.AllowRow(grdMain)) { InputMode = DBUtility.ClsPub.Enum_InputMode.InputMode_Modify; RefreshTool(); Init(); } } private void sz_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (CurNode != null) { if (CurNode.Name == "T0") { MessageBox.Show("´Ë½Úµã²»¿Éɾ³ý£¡"); } else { } } } private void cmdLoadTree_Click(object sender, EventArgs e) { Display(); Gy_Department_Load(sender, e); LoadTree(TreeView, imageList1, this.Text); } private void xz_Click(object sender, EventArgs e) { if (CurNode.Text == "") { MessageBox.Show("ÇëÑ¡ÔñÐèÒªÐÂÔöÖ°Ô±µÄ²¿ÃÅ"); return; } else { if (CurNode.Text == "ͨѶ¼") { MessageBox.Show("´Ë½Úµã²»¿ÉÐÂÔöÖ°Ô±±í"); return; } else { ofrm_add1.id = CurNode.Name.Replace("T", ""); ofrm_add1.oDeptid = CurNode.Name.Replace("T", ""); ofrm_add1.zt = true; ofrm_add1.ShowDialog(); Display(); } } } private void grdMain_DoubleClick(object sender, EventArgs e) { if (grdMain.CurrentRow == null) { return; } else { int col= Fun_GetCol("FitemID"); ofrm_add1.id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString(); ofrm_add1.zt = false; ofrm_add1.ShowDialog(); LoadTree(TreeView, imageList1, this.Text); Display(); } } private Int32 Fun_GetCol(string sCol) { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); } //ÐÂÔöʱÇå¿ÕÐÅÏ¢ private void Sub_Clear() //Lock { //txtFnumber.Text = ""; //txtFname.Text = ""; //txtTel.Text = ""; //txtInnerTel.Text = ""; //txtMobile.Text = ""; //txtEmail.Text = ""; //txtVirtual.Text = ""; //txtFRemark.Text = ""; } //³õʼ»¯½çÃæ private bool Init() { long sItemID; if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_AddNew) { Sub_Clear(); RefreshTool(); return true; } else { //µÃµ½HITEMID sItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HItemIDCol].Value); //¼ì²éÊÇ·ñ´æÔÚ //if (oDeptHlp.GetInfoByID(sItemID)) //{ // ShowData(sItemID); // //txtHNumber.Focus(); // return true; //} //else //{ // MessageBox.Show("ÄúÑ¡ÔñµÄÏîÄ¿ÒѾ­²»´æÔÚ£¡" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); // return false; //} return false; } } private void frm_txl1_Load(object sender, EventArgs e) { Display(); Gy_Department_Load(sender, e); LoadTree(TreeView, imageList1, this.Text); } private void xg_Click(object sender, EventArgs e) { if (grdMain.CurrentRow == null) { return; } else { int col = Fun_GetCol("FitemID"); ofrm_add1.id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString(); ofrm_add1.zt = false; ofrm_add1.ShowDialog(); Display(); } } private void sc_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); if (grdMain.CurrentRow == null) { return; } else { DialogResult dr = MessageBox.Show("È·¶¨ÒªÉ¾³ý´ËÖ°Ô±ÐÅÏ¢Âð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { int col = Fun_GetCol("FitemID"); string id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString(); oCn.RunProc("DELETE FROM EmployeeCon WHERE FitemID =" + id + " ", ref DBUtility.ClsPub.sExeReturnInfo); LoadTree(TreeView, imageList1, this.Text); Display(); MessageBox.Show("Ö°Ô±ÐÅÏ¢ÒÑɾ³ý"); } } } private void tc_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); this.Close(); } } }