/// <summary> /// 删除部门 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton4_Click(object sender, EventArgs e) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; if (it.parent == "") { MessageBox.Show("禁止删除最高级别组织!"); return; } if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { DepartmentModel dep = new DepartmentModel(Convert.ToInt32(it.id)); MessageModel msg = ctrl.del(dep); if (msg.Code == 0) { //treeView1.SelectedNode.Parent.Nodes.Remove(treeView1.SelectedNode); treeView1.SelectedNode.Remove(); } else { MessageBox.Show(msg.Msg); } } }
private void toolStripButton3_Click(object sender, EventArgs e) { //if(this.dataGridView1.CurrentCell != null) //{ // bool isActive = Convert.ToBoolean(this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["isActive"].Value); // MessageModel msg = ctrl.switchStatus(Convert.ToInt32(this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["id"].Value), isActive); // if(msg.Code == 0) // { // this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["isActive"].Value = !isActive; // if (isActive) this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["status"].Value = "注销"; // else this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["status"].Value = "活动"; // } // MessageBox.Show(msg.Msg); //} if (treeView1.SelectedNode != null) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; MessageModel msg = ctrl.switchStatus(it.id, it.isActive); if (msg.Code == 0) { if (it.isActive) { treeView1.SelectedNode.ForeColor = Color.Red; } else { treeView1.SelectedNode.ForeColor = Color.Black; } it.isActive = !it.isActive; } MessageBox.Show(msg.Msg); } }
public void LoadRoleData(int depid) { dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect; if (depid == -1) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; depid = Convert.ToInt32(it.id); } else { treeView1.SelectedNode = map_id_tn[depid.ToString()]; } dtData = rc.getbyDepId(depid); dt = new DataTable(); DataColumn dcNO = new DataColumn("no"); DataColumn dcName = new DataColumn("name"); dt.Columns.Add(dcNO); dt.Columns.Add(dcName); for (int i = 0; i < dtData.Rows.Count; i++) { DataRow dr = dt.NewRow(); dr[0] = dtData.Rows[i]["id"].ToString(); dr[1] = dtData.Rows[i]["name"].ToString(); dt.Rows.Add(dr); ////if(data.Rows[i]["isActive"].ToString() == "1") dr[1] = "激活"; ////else dr[1] = "注销"; //dt.Rows.Add(dr);data.Rows[i]["id"].ToString(), dt.Rows[i]["name"].ToString(), dt.Rows[i]["departmentId"].ToString() } dataGridView1.DataSource = dt; }
private void toolStripButton1_Click(object sender, EventArgs e) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; RolePopup popup = new RolePopup(this, it.id); popup.Show(); }
private void button1_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; CategorySet(this, new CategoryEventArgs(it.id, it.name)); } this.Close(); }
/// <summary> /// 新建下一级部门 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton2_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; this.createDepartment(it.id);//, treeView1.SelectedNode } else { this.createDepartment(""); } }
private void toolStripButton4_Click(object sender, EventArgs e) { this.panel2.Visible = true; currentId = -1; if (treeView1.SelectedNode != null) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; parent = it.id; } else { parent = -1; } this.textBox1.Text = ""; }
private void toolStripButton2_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { this.panel2.Visible = true; //currentId = Convert.ToInt32(this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["id"].Value); //this.textBox1.Text = this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["name"].Value.ToString(); innerTag it = (innerTag)treeView1.SelectedNode.Tag; currentId = it.id; this.textBox1.Text = it.name; } else { MessageBox.Show("请选择一项。"); } }
/// <summary> /// 新建同级部门 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton1_Click(object sender, EventArgs e) { //this.createDepartment(""); if (treeView1.SelectedNode != null) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; if (it.parent == "") { MessageBox.Show("禁止创建同级最高级别组织!"); return; } this.createDepartment(it.parent);//, treeView1.SelectedNode.Parent } else { this.createDepartment(""); } }
private DataRow tag2dr(innerTag obj) { var dr = dt_tree.NewRow(); dr["id"] = obj.id; dr["name"] = obj.name; dr["mnum"] = obj.mnum; dr["level"] = obj.level; dr["specifications"] = obj.specifications; dr["metering"] = obj.metering; dr["remark"] = obj.remark; dr["type"] = obj.type; dr["quantity"] = Math.Round(obj.quantity, 2); dr["price"] = Math.Round(obj.price, 2); dr["amount"] = Math.Round(obj.amount, 2); dr["bottom"] = obj.bottom; return(dr); }
/// <summary> /// 更新部门 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton3_Click(object sender, EventArgs e) { string text = treeView1.SelectedNode.Text != null ? treeView1.SelectedNode.Text : ""; string str = Interaction.InputBox("请输入名称", "输入名称", text); if (str.Count() != 0) { innerTag it = (innerTag)treeView1.SelectedNode.Tag; DepartmentModel dep = new DepartmentModel(Convert.ToInt32(it.id), str); MessageModel msg = ctrl.set(dep); if (msg.Code == 0) { this.treeView1.SelectedNode.Text = str; } else { MessageBox.Show(msg.Msg); } } }
private List <int> recursionGet(List <int> ids) { DataTable dt = ctrl.getbyid2(ids); List <int> list = new List <int>(); List <int> list2 = new List <int>(); for (int i = 0; i < dt.Rows.Count; i++) { int children; if (dt.Rows[i]["children"] != DBNull.Value) { children = Convert.ToInt32(dt.Rows[i]["children"]); } else { children = Convert.ToInt32(dt.Rows[i]["materiel"]); } int parent = Convert.ToInt32(dt.Rows[i]["id"]); int dtl = Convert.ToInt32(dt.Rows[i]["did"]); int dparent = Convert.ToInt32(dt.Rows[i]["dparent"]); list2.Add(dtl); TreeNode childNode = map_id_tn[dparent].Nodes.Add(dt.Rows[i]["mcname"].ToString()); var ctag = new innerTag(children, dtl, dt.Rows[i]["mcnum"].ToString(), dt.Rows[i]["mcname"].ToString(), dparent, level, dt.Rows[i]["msspe"].ToString(), dt.Rows[i]["mcmetering"].ToString(), dt.Rows[i]["remark"].ToString(), dt.Rows[i]["mctype"].ToString()); ((innerTag)map_id_tn[dparent].Tag).scale = ((innerTag)map_id_tn[dparent].Tag).quantity / Convert.ToDouble(dt.Rows[i]["mainqty"]); ctag.quantity = ((innerTag)map_id_tn[dparent].Tag).scale * Convert.ToDouble(dt.Rows[i]["dtlqty"]); //ctag.scale = ctag.quantity / Convert.ToDouble(dt.Rows[i]["mainqty"]); if (dt.Rows[i]["children"] != DBNull.Value) { list.Add(dtl); } else if (dt.Rows[i]["mctype"].ToString() == "外购件") { ctag.price = Convert.ToDouble(dt.Rows[i]["normprice"]); ctag.amount = ctag.quantity * ctag.price; ctag.bottom = true; } else { ctag.price = 0; ctag.amount = 0; ctag.bottom = true; } childNode.Tag = ctag; if (!map_id_tn.ContainsKey(dtl)) { map_id_tn.Add(dtl, childNode); } } level++; if (level > 10) { MessageBox.Show("层级超过10层,不能显示!"); ISBREAK = true; return(new List <int>()); } if (list.Count > 0) { List <int> list_r = recursionGet(list); for (int i = 0; i < list_r.Count; i++) { var tagtemp = ((innerTag)map_id_tn[list_r[i]].Tag); if (tagtemp.parent != null) { ((innerTag)map_id_tn[Convert.ToInt32(tagtemp.parent)].Tag).amount += tagtemp.amount; } //MessageBox.Show(tagtemp.name + "|"+ ); } } return(list2); }
/// <summary> /// bom树 /// </summary> private void loadTreeData() { treeView1.Nodes.Clear(); DataTable dt = ctrl.getbyid(new List <int> { id }); TreeNode node = treeView1.Nodes.Add(dt.Rows[0]["name"].ToString()); int mainid = Convert.ToInt32(dt.Rows[0]["id"]); var tag = new innerTag(mainid, mainid, dt.Rows[0]["mnum"].ToString(), dt.Rows[0]["name"].ToString(), null, level, dt.Rows[0]["specifications"].ToString(), dt.Rows[0]["metering"].ToString(), "", dt.Rows[0]["type"].ToString()); tag.quantity = 1; tag.scale = tag.quantity / Convert.ToDouble(dt.Rows[0]["mainqty"]); node.Tag = tag; level++; map_id_tn.Add(mainid, node); List <int> list = new List <int>(); List <int> list2 = new List <int>(); for (int i = 0; i < dt.Rows.Count; i++) { TreeNode childNode = node.Nodes.Add(dt.Rows[i]["mcname"].ToString()); int children; if (dt.Rows[i]["children"] != DBNull.Value) { children = Convert.ToInt32(dt.Rows[i]["children"]); } else { children = Convert.ToInt32(dt.Rows[i]["materiel"]); } int parent = Convert.ToInt32(dt.Rows[i]["id"]); int dtl = Convert.ToInt32(dt.Rows[i]["did"]); list2.Add(dtl); var ctag = new innerTag(children, dtl, dt.Rows[i]["mcnum"].ToString(), dt.Rows[i]["mcname"].ToString(), parent, level, dt.Rows[i]["msspe"].ToString(), dt.Rows[i]["mcmetering"].ToString(), dt.Rows[i]["remark"].ToString(), dt.Rows[i]["mctype"].ToString()); ctag.quantity = ((innerTag)map_id_tn[parent].Tag).scale * Convert.ToDouble(dt.Rows[i]["dtlqty"]); //ctag.scale = ctag.quantity / Convert.ToDouble(dt.Rows[i]["mainqty"]); childNode.Tag = ctag; if (!map_id_tn.ContainsKey(dtl)) { map_id_tn.Add(dtl, childNode); } if (dt.Rows[i]["children"] != DBNull.Value) { list.Add(dtl); } else if (dt.Rows[i]["mctype"].ToString() == "外购件") { ctag.price = Convert.ToDouble(dt.Rows[i]["normprice"]); ctag.amount = ctag.quantity * ctag.price; ctag.bottom = true; } else { ctag.price = 0; ctag.bottom = true; } } level++; if (list.Count > 0) { List <int> list_r = recursionGet(list); for (int i = 0; i < list_r.Count; i++) { var tagtemp = ((innerTag)map_id_tn[list_r[i]].Tag); if (tagtemp.parent != null) { ((innerTag)map_id_tn[Convert.ToInt32(tagtemp.parent)].Tag).amount += tagtemp.amount; } } } if (ISBREAK) { this.Close(); } for (int i = 0; i < list2.Count; i++) { var tagtemp = ((innerTag)map_id_tn[list2[i]].Tag); ((innerTag)map_id_tn[Convert.ToInt32(tagtemp.parent)].Tag).amount += tagtemp.amount; } foreach (var item in map_id_tn.Values) { if (((innerTag)item.Tag).price == 0) { ((innerTag)item.Tag).price = ((innerTag)item.Tag).amount / ((innerTag)item.Tag).quantity; } } this.treeView1.ExpandAll(); }