using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace PlanM { public partial class Sc_ICBomBillMuiList_K3 : Form { private int HItemIDCol = 0; private int HNumberCol = 0; const string ViewName = "h_v_Sc_ICBomBillMuiList_K3"; const string ModName = "BOM多级展开"; //权限 public const string ModRightName = "KF_ICInventory_K3"; public const string ModRightNameEdit = ModRightName + "_Edit"; public const string ModRightNameCheck = ModRightName + "_Check"; // public long HItemID;//项目ID public long HItemGroupID; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); // public long HBomID = 0; TreeNode CurNode = new TreeNode(); //拆分字符 char spChar =Convert.ToChar( "~"); public Sc_ICBomBillMuiList_K3() { InitializeComponent(); } //以下代码基本不需要修改 #region 固定代码 private void wl_Click(object sender, EventArgs e) { LoadTree(); DisplaySub(); Display(); } //窗体加载 private void KF_ICInventory_Load(object sender, EventArgs e) { lblCaption.Text = ModName; this.Text = ModName; LoadTree(); initGrid(); } //退出模块 private void tc_Click(object sender, EventArgs e) { this.Close(); } //刷新 private void xs_Click(object sender, EventArgs e) { DisplaySub(); Display(); } //查询 private void cx_Click(object sender, EventArgs e) { DisplaySub(); Display(); } //得到对应列 private Int32 Fun_GetCol(string sCol) { for (int c = 0; c < grdMain.ColumnCount; c++) { if (DBUtility.ClsPub.isStrNull(grdMain.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper()) { return c; } } return 0; } private Int32 Fun_GetColSub(string sCol) { for (int c = 0; c < grdSub.ColumnCount; c++) { if (DBUtility.ClsPub.isStrNull(grdSub.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper()) { return c; } } return 0; } private Int32 Fun_GetColTree(string sCol) { for (int c = 0; c < grdTree.ColumnCount; c++) { if (DBUtility.ClsPub.isStrNull(grdTree.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper()) { return c; } } return 0; } //树型 单击 private void tv_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { CurNode = e.Node; if (CurNode != null) { if (CurNode.Nodes.Count == 0) { LoadAllNodes(CurNode); } //找到选中结点 DisplayTree(); //Display(); //DisplaySub(); } } //选中行是否正常 private bool AllowRow() { if (grdMain.CurrentRow.Index >= 0 && grdMain.CurrentRow.Index <= grdMain.RowCount - 1) return true; else return false; } private void bclk_Click(object sender, EventArgs e) { //保存列宽 DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); DBUtility.ClsPub.SaveGridView(grdSub, this.Name + "grdSub", DBUtility.ClsPub.AppPath); DBUtility.ClsPub.SaveGridView(grdTree, this.Name + "grdTree", DBUtility.ClsPub.AppPath); } private void mrlk_Click(object sender, EventArgs e) { DBUtility.ClsPub.DefaultGridView(grdMain); DBUtility.ClsPub.DefaultGridView(grdSub); //参数解释 开始列 ,结束列,是否以最大列宽为准,最小列宽 DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath); DBUtility.ClsPub.SaveGridView(grdSub, this.Name, DBUtility.ClsPub.AppPath); } //时间控件 private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; DisplaySub(); Display(); } //初始化GRID private void initGrid() { //主表 grdMain.RowTemplate.Height = 18; grdMain.RowTemplate.MinimumHeight = 18; grdMain.ColumnHeadersHeight = 25; grdMain.RowHeadersVisible = false; grdMain.ColumnHeadersVisible = true; grdMain.ColumnCount = 0; grdMain.RowCount = 0; //格式化 //表格设置 grdMain.RowsDefaultCellStyle.SelectionForeColor = Color.White; grdMain.RowsDefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdMain.DefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdMain.DefaultCellStyle.SelectionForeColor = Color.White; grdMain.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; grdMain.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect; grdMain.ReadOnly = true; grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //允许用户调整列宽 grdMain.EnableHeadersVisualStyles = false; //网格标题 样式 grdMain.AllowUserToAddRows = false; //是否允许自增--否 grdMain.AllowUserToDeleteRows = false; //是否允许删除--否 grdMain.AllowUserToResizeColumns = true; //允许调整列宽--是 grdMain.AllowUserToResizeRows = false; //允许调整行高--否 grdMain.AllowUserToOrderColumns = true; //允许 拖拽列 grdMain.BackgroundColor = Color.White; grdMain.GridColor = Color.LightGray; //网格线颜色 grdMain.ShowCellToolTips = true; grdMain.CellBorderStyle = DataGridViewCellBorderStyle.Single; //grdMain.ColumnHeadersDefaultCellStyle.BackColor = Color.AliceBlue; // DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);//设置列宽 //子表 grdSub.RowTemplate.Height = 18; grdSub.RowTemplate.MinimumHeight = 18; grdSub.ColumnHeadersHeight = 25; grdSub.RowHeadersVisible = false; grdSub.ColumnHeadersVisible = true; grdSub.ColumnCount = 0; grdSub.RowCount = 0; //格式化 //表格设置 grdSub.RowsDefaultCellStyle.SelectionForeColor = Color.White; grdSub.RowsDefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdSub.DefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdSub.DefaultCellStyle.SelectionForeColor = Color.White; grdSub.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; grdSub.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; grdSub.SelectionMode = DataGridViewSelectionMode.FullRowSelect; grdSub.ReadOnly = true; grdSub.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //允许用户调整列宽 grdSub.EnableHeadersVisualStyles = false; //网格标题 样式 grdSub.AllowUserToAddRows = false; //是否允许自增--否 grdSub.AllowUserToDeleteRows = false; //是否允许删除--否 grdSub.AllowUserToResizeColumns = true; //允许调整列宽--是 grdSub.AllowUserToResizeRows = false; //允许调整行高--否 grdSub.AllowUserToOrderColumns = true; //允许 拖拽列 grdSub.BackgroundColor = Color.White; grdSub.GridColor = Color.LightGray; //网格线颜色 grdSub.ShowCellToolTips = true; grdSub.CellBorderStyle = DataGridViewCellBorderStyle.Single; //grdSub.ColumnHeadersDefaultCellStyle.BackColor = Color.AliceBlue; // DBUtility.ClsPub.GetGridView(grdSub, this.Name + "grdSub", DBUtility.ClsPub.AppPath);//设置列宽 //子表 grdTree.RowTemplate.Height = 18; grdTree.RowTemplate.MinimumHeight = 18; grdTree.ColumnHeadersHeight = 25; grdTree.RowHeadersVisible = false; grdTree.ColumnHeadersVisible = true; grdTree.ColumnCount = 0; grdTree.RowCount = 0; //格式化 //表格设置 grdTree.RowsDefaultCellStyle.SelectionForeColor = Color.White; grdTree.RowsDefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdTree.DefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdTree.DefaultCellStyle.SelectionForeColor = Color.White; grdTree.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; grdTree.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; grdTree.SelectionMode = DataGridViewSelectionMode.FullRowSelect; grdTree.ReadOnly = true; grdTree.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //允许用户调整列宽 grdTree.EnableHeadersVisualStyles = false; //网格标题 样式 grdTree.AllowUserToAddRows = false; //是否允许自增--否 grdTree.AllowUserToDeleteRows = false; //是否允许删除--否 grdTree.AllowUserToResizeColumns = true; //允许调整列宽--是 grdTree.AllowUserToResizeRows = false; //允许调整行高--否 grdTree.AllowUserToOrderColumns = true; //允许 拖拽列 grdTree.BackgroundColor = Color.White; grdTree.GridColor = Color.LightGray; //网格线颜色 grdTree.ShowCellToolTips = true; grdTree.CellBorderStyle = DataGridViewCellBorderStyle.Single; //grdTree.ColumnHeadersDefaultCellStyle.BackColor = Color.AliceBlue; // DBUtility.ClsPub.GetGridView(grdTree, this.Name + "grdTree", DBUtility.ClsPub.AppPath);//设置列宽 } #endregion //显示列表 private void Display() { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); DataSet DSet ; string sSql = ""; string sWhere = ""; long HParentID = 0; //树形节点 if (CurNode.Name != "") { HParentID = DBUtility.ClsPub.isLong(CurNode.Name.Trim().Substring(1, CurNode.Name.Trim().Length - 1)); } HParentID = HBomID; //过滤条件 sSql = "exec h_p_K3_ICBomBillMui_Top " + HParentID.ToString(); //执行SQL DSet = SubCn.RunProcReturn(sSql, "h_p_K3_ICBomBillMui_Top"); //生成首行标题 if (DSet == null) { return; } // for (int i = 0; i < grdMain.ColumnCount; i++) { grdMain.Columns[i].Frozen = false; } // grdMain.DataSource = DSet.Tables[0].DefaultView; //设置合计列 new //string sTotalCol = ""; //sTotalCol = ClsPub.GetTotalCols(DSet); //string[] sT; //sT = sTotalCol.Split(Convert.ToChar(",")); //oSumGrid.BuildTotalCols(sT); // //合计 //grdMain.Rows.Add(); //加载列宽,隐藏列 for (int i = 0; i < grdMain.ColumnCount; i++) { grdMain.Columns[i].Width = 100; //if (frmCondition.cmbHComplete.Text == "否") //{ // grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; //} //else //{ grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; //} if (grdMain.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h") { grdMain.Columns[i].Visible = false; } else { grdMain.Columns[i].Visible = true; } } DBUtility.ClsPub.GetGridView(this.grdMain, this.Name, DBUtility.ClsPub.AppPath); //画线 GraphLine(); //冻结 //int FrCol = ClsPub.isInt(frmCondition.txtFrozenCol.Text); //if (FrCol < grdMain.ColumnCount) //{ // grdMain.Columns[FrCol].Frozen = true; //} // new //Total(); } //显示列表--子表 private void DisplaySub() { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; long HParentID = 0; //树形节点 if (CurNode.Name != "") { HParentID = DBUtility.ClsPub.isLong(CurNode.Name.Trim().Substring(1, CurNode.Name.Trim().Length - 1)); } HParentID = HBomID; //过滤条件 sSql = "exec h_p_K3_ICBomBillMuiList " + HParentID.ToString(); //执行SQL DSet = SubCn.RunProcReturn(sSql, "h_p_K3_ICBomBillMuiList"); //生成首行标题 if (DSet == null) { return; } // for (int i = 0; i < grdSub.ColumnCount; i++) { grdSub.Columns[i].Frozen = false; } // grdSub.DataSource = DSet.Tables[0].DefaultView; //设置合计列 new //string sTotalCol = ""; //sTotalCol = ClsPub.GetTotalCols(DSet); //string[] sT; //sT = sTotalCol.Split(Convert.ToChar(",")); //oSumGrid.BuildTotalCols(sT); // //合计 //grdSub.Rows.Add(); //加载列宽,隐藏列 for (int i = 0; i < grdSub.ColumnCount; i++) { grdSub.Columns[i].Width = 100; //if (frmCondition.cmbHComplete.Text == "否") //{ // grdSub.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; //} //else //{ grdSub.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; //} if (grdSub.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h") { grdSub.Columns[i].Visible = false; } else { grdSub.Columns[i].Visible = true; } } int HColourCol = Fun_GetColSub("HColor"); //设置网格背景颜色 for (int i = 0; i < grdSub.RowCount; i++) { if (DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[HColourCol].Value) == "蓝色") { grdSub.Rows[i].DefaultCellStyle.BackColor = Color.Lavender; } if (DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[HColourCol].Value) == "粉色") { grdSub.Rows[i].DefaultCellStyle.BackColor = Color.Pink; } } DBUtility.ClsPub.GetGridView(this.grdSub, this.Name + "grdSub", DBUtility.ClsPub.AppPath); //画线 GraphLine(); //冻结 //int FrCol = ClsPub.isInt(frmCondition.txtFrozenCol.Text); //if (FrCol < grdSub.ColumnCount) //{ // grdSub.Columns[FrCol].Frozen = true; //} // new //Total(); SetRowColor(); } //显示列表 private void DisplayTree() { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; long HParentID = 0; //树形节点 if (CurNode.Name != "") { HParentID = DBUtility.ClsPub.isLong(CurNode.Name.Trim().Substring(1, CurNode.Name.Trim().Length - 1)); } //过滤条件 sSql = "select hinterid,BOM编号,hitemid,产品代码,产品名称,规格型号,hparentid,状态 from h_v_K3_ICBomMainList where hparentid=" + HParentID.ToString() + " order by 产品代码"; //执行SQL DSet = SubCn.RunProcReturn(sSql, "h_v_K3_ICBomMainList"); //生成首行标题 if (DSet == null) { return; } // for (int i = 0; i < grdTree.ColumnCount; i++) { grdTree.Columns[i].Frozen = false; } // grdTree.DataSource = DSet.Tables[0].DefaultView; //设置合计列 new //string sTotalCol = ""; //sTotalCol = ClsPub.GetTotalCols(DSet); //string[] sT; //sT = sTotalCol.Split(Convert.ToChar(",")); //oSumGrid.BuildTotalCols(sT); // //合计 //grdTree.Rows.Add(); //加载列宽,隐藏列 for (int i = 0; i < grdTree.ColumnCount; i++) { grdTree.Columns[i].Width = 100; //if (frmCondition.cmbHComplete.Text == "否") //{ // grdTree.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; //} //else //{ grdTree.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; //} if (grdTree.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h") { grdTree.Columns[i].Visible = false; } else { grdTree.Columns[i].Visible = true; } } DBUtility.ClsPub.GetGridView(this.grdTree, this.Name + "grdTree", DBUtility.ClsPub.AppPath); //画线 //GraphLine(); //冻结 //int FrCol = ClsPub.isInt(frmCondition.txtFrozenCol.Text); //if (FrCol < grdTree.ColumnCount) //{ // grdTree.Columns[FrCol].Frozen = true; //} // new //Total(); } //显示列表 private void DisplayTree2() { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); DataSet DSet; string sSql = ""; string sWhere = " where 1=1 "; long HParentID = 0; if (txtHNumber.Text.Trim() != "") { sWhere = sWhere + " and 产品代码 like '%" + txtHNumber.Text.Trim() + "%'"; } if (txtHName.Text.Trim() != "") { sWhere = sWhere + " and 产品名称 like '%" + txtHName.Text.Trim() + "%'"; } if (txtHModel.Text.Trim() != "") { sWhere = sWhere + " and 规格型号 like '%" + txtHModel.Text.Trim() + "%'"; } if (txtHPicNo.Text.Trim() != "") { sWhere = sWhere + " and 图号 like '%" + txtHPicNo.Text.Trim() + "%'"; } //过滤条件 sSql = "select hinterid,BOM编号,hitemid,产品代码,产品名称,规格型号,hparentid,状态 from h_v_K3_ICBomMainList " + sWhere + " order by 产品代码"; //执行SQL DSet = SubCn.RunProcReturn(sSql, "h_v_K3_ICBomMainList"); //生成首行标题 if (DSet == null || DSet.Tables[0].Rows.Count ==0) { MessageBox.Show("没有返回任何记录!"); return; } // for (int i = 0; i < grdTree.ColumnCount; i++) { grdTree.Columns[i].Frozen = false; } // grdTree.DataSource = DSet.Tables[0].DefaultView; //加载列宽,隐藏列 for (int i = 0; i < grdTree.ColumnCount; i++) { grdTree.Columns[i].Width = 100; grdTree.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; if (grdTree.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h") { grdTree.Columns[i].Visible = false; } else { grdTree.Columns[i].Visible = true; } } DBUtility.ClsPub.GetGridView(this.grdTree, this.Name + "grdTree", DBUtility.ClsPub.AppPath); } private void SetRowColor() { for (int i = 0; i <= grdSub.Rows.Count - 1; i++) { if (DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[Fun_GetColSub("物料属性")].Value) == "自制" || DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[Fun_GetColSub("物料属性")].Value) == "委外加工") { if (DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[Fun_GetColSub("HStatus")].Value) == "") { grdSub.Rows[i].DefaultCellStyle.ForeColor = Color.Red; } else { grdSub.Rows[i].DefaultCellStyle.ForeColor = Color.Black; } } } } //划线 private void GraphLine() { //找到主表ID和子表ID的 范围 int MainIDCol = Fun_GetCol("hmaterid"); int SubIDCol = Fun_GetCol("hsubid"); long HMainID = 0; bool b = false; long n = 0; //循环所有行 for (int i = 0; i < grdMain.RowCount; i++) { if (HMainID == 0) { HMainID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[MainIDCol].Value); n++; } else { if (HMainID == DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[MainIDCol].Value)) { //if (frmCondition.cmbHComplete.Text == "否") //{ // 区域性清空 // SetDataGrid(i, MainIDCol + 1, i, SubIDCol - 1, ""); //} } else { HMainID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[MainIDCol].Value); b = !b; n++; } } if (b) { grdMain.Rows[i].DefaultCellStyle.BackColor = Color.White; } else { grdMain.Rows[i].DefaultCellStyle.BackColor = Color.Lavender; } } //显示 //lbldj.Text = "查询出 " + n.ToString() + " 张单据"; //lbljl.Text = "共有 " + grdMain.RowCount.ToString() + " 条记录"; } //加载子结点 private void LoadAllNodes(TreeNode sNode) { if (sNode != null) { try { sNode.Nodes.Clear(); DataSet Ds = oCn.RunProcReturn("exec h_p_K3_BOMGroup " + sNode.Name.Trim().Substring(1, sNode.Name.Trim().Length - 1), "h_p_K3_BOMGroup"); for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["FKey"].ToString(), Ds.Tables[0].Rows[i]["FText"].ToString(), 0, 1); } sNode.Expand(); } catch (Exception e) { MessageBox.Show("加载子项目失败!" + e.Message, "提示"); } } } //加载树形 private void LoadTree() { try { tv.Nodes.Clear(); tv.ImageList = imageList1; TreeNode sNode = tv.Nodes.Add("T0", "BOM单", 0, 1); LoadAllNodes(sNode); } catch (Exception e) { MessageBox.Show("加载树型失败!" + e.Message, "提示"); } } //合计 new private void Total() { if (grdMain.Rows.Count > 0 && grdMain.ColumnCount > 0) { //oSumGrid.SetGridsum(); //oSumGrid.Total(); } } //合计 new private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { //Total(); } //合计 new private void grdMain_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { //Total(); } private void Bom_Click(object sender, EventArgs e) { //得到单据号 long HMaterID = 0; string sType = ""; if (grdSub.CurrentRow == null) return; HMaterID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetColSub("HMaterID")].Value); sType = DBUtility.ClsPub.isStrNull(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetColSub("物料属性")].Value); if (HMaterID == 0) return; if (sType != "自制" && sType != "委外加工") { MessageBox.Show("所选物料不是自制件,不允许生成BOM!"); return; } Gy_ICBomBill_K3 oICBomAdd = new Gy_ICBomBill_K3(); oICBomAdd.sHMaterID = HMaterID; oICBomAdd.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oICBomAdd.Show(); } private void gy_Click(object sender, EventArgs e) { long HMaterID = 0; if (grdSub.CurrentRow == null) return; HMaterID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetColSub("HMaterID")].Value); if (HMaterID == 0) return; Gy_ICBomBill_Routing oRouting = new Gy_ICBomBill_Routing(); oRouting.sHMaterID = HMaterID; oRouting.Show(); } private void cmdOK_Click(object sender, EventArgs e) { DataSet oDs = new DataSet(); HBomID = 0; if (txtHNumber.Text.Trim() == "" & txtHName.Text.Trim() == "" & txtHModel.Text.Trim() == "" & txtHPicNo.Text.Trim() == "") { MessageBox.Show("请至少输入一个过滤条件!"); return; } DisplayTree2(); //显示 树形 oDs = oCn.RunProcReturn("exec h_p_K3_Sc_GetBomIDByInfo '" + txtHNumber.Text.Trim() + "','" + txtHName.Text.Trim() + "','" + txtHModel.Text.Trim() + "','" + txtHPicNo.Text.Trim() + "'", "gy_czygl"); if (oDs.Tables[0].Rows.Count == 0 || oDs == null) return; HBomID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]); // DisplaySub(); Display(); } private void grdTree_DoubleClick(object sender, EventArgs e) { if (grdTree.CurrentRow == null) return; HBomID = DBUtility.ClsPub.isLong(grdTree.Rows[grdTree.CurrentRow.Index].Cells[Fun_GetColTree("hinterid")].Value); // DisplaySub(); Display(); } private void grdMain_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { //得到单据号 long HMaterID = 0; string sType = ""; if (grdMain.CurrentRow == null) return; HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HMaterID")].Value); if (HMaterID == 0) return; Gy_ICBomBill_K3 oICBomAdd = new Gy_ICBomBill_K3(); oICBomAdd.sHMaterID = HMaterID; oICBomAdd.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oICBomAdd.Show(); } public Gy_ICBomBill_K3 oFrm; private void xg_Click(object sender, EventArgs e) { //得到单据号 Int64 lngMaterID = 0; if (grdSub.CurrentRow == null) return; lngMaterID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetColSub("HMaterID")].Value); Int64 lngBillKey = 0; //根据物料获取 已启用 BOM内码 DAL.ClsGy_ICBomBill_K3 oBill = new DAL.ClsGy_ICBomBill_K3(); if (oBill.Get_BOMIDByMaterID(lngMaterID,ref lngBillKey,ref DBUtility.ClsPub.sExeReturnInfo)==false) { MessageBox.Show("没有找到启用BOM!"); return; } if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { oFrm = new Gy_ICBomBill_K3(); oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; oFrm.BillOld = oBill; oFrm.ShowDialog(); } else { MessageBox.Show("BOM单据未找到", "提示"); } oBill = null; } private void pd_Click(object sender, EventArgs e) { DAL.ClsGy_RoutingBill oBill = new DAL.ClsGy_RoutingBill(); //得到单据号 long HMaterID = 0; string sType = ""; //判断子表 自制件是否有工艺路线 for (int i = 0; i <= grdSub.Rows.Count - 1; i++) { HMaterID = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[Fun_GetColSub("HMaterID")].Value); sType = DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[Fun_GetColSub("物料属性")].Value); if (sType == "自制" || sType == "委外加工") { if (!oBill.IsExistRouting(HMaterID)) { grdSub.Rows[i].DefaultCellStyle.BackColor = Color.DarkOrange; } else { grdSub.Rows[i].DefaultCellStyle.BackColor = Color.White; } } } //判断主表 自制件是否有工艺路线 for (int i = 0; i <= grdMain.Rows.Count - 1; i++) { HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[Fun_GetCol("HMaterID")].Value); sType = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("物料属性")].Value); if (sType == "自制" || sType == "委外加工") { if (!oBill.IsExistRouting(HMaterID)) { grdMain.Rows[i].DefaultCellStyle.BackColor = Color.DarkOrange; grdMain.Rows[i].Selected = false; } else { grdMain.Rows[i].DefaultCellStyle.BackColor = Color.Black; } } } } private void gylx_Click(object sender, EventArgs e) { Gy_RoutingBill oFrm = new Gy_RoutingBill(); oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oFrm.ShowDialog(); } } }