Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtMaterialID.Tag != null)
            {
                DialogResult dr = MessageBox.Show("确定要删除选择的物料(母件)数据?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dr == DialogResult.OK)
                {
                    MaterialBOMManage MaterialBOMManage = new MaterialBOMManage();
                    MaterialBOMManage.DetailMaterialBom(txtMaterialID.Tag.ToString());

                    //写日志
                    SysLog.AddOperateLog(SysParams.UserName, "BOM数据", "删除BOM", SysParams.UserName + "用户删除了BOM,物料:" + txtMaterialID.Tag.ToString() + ",物料名称:" + txtMaterialID.Text);

                    txtMaterialID.Text   = "";
                    txtMaterialID.Tag    = "";
                    txtMaterialName.Text = "";
                    txtSpec.Text         = "";
                    txtUnit.Text         = "";
                    txtRemark.Text       = "";

                    treeView1.Nodes.Clear();

                    gridView2.SelectAll();
                    gridView2.DeleteSelectedRows();
                }
            }
        }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (gridView1.RowCount >= 0)
            {
                DialogResult dr = MessageBox.Show("确定要删除选择的物料(母件)数据?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dr == DialogResult.OK)
                {
                    MaterialBOMManage MaterialBOMManage = new MaterialBOMManage();
                    MaterialBOMManage.DetailMaterialBom(gridView1.GetFocusedRowCellValue(gridMaterialGuid).ToString());

                    //写日志
                    SysLog.AddOperateLog(SysParams.UserName, "BOM数据", "删除BOM", SysParams.UserName + "用户删除了BOM,物料:" + gridView1.GetFocusedRowCellValue(gridMaterialGuid).ToString() + "," + gridView1.GetFocusedRowCellValue(gridMaterialName).ToString());


                    LoadMaterialBom();

                    if (gridView1.RowCount >= 0)
                    {
                        LoadMaterialBomDetail(gridView1.GetFocusedRowCellValue(gridMaterialGuid).ToString());
                    }
                }
            }
        }
Ejemplo n.º 3
0
        //计算物料需求
        private void btnJS_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                txtRemark.Focus();
                gridView1.UpdateCurrentRow();

                MaterialMRPPlanManage MaterialMRPPlanManage = new MaterialMRPPlanManage();
                MaterialBOMManage     MaterialBOMManage     = new MaterialBOMManage();
                bool IsExistBom   = false;
                bool IsExistNoBom = false;
                //string strMaterialID = "";
                //string strMaterialName = "";
                //检查此客户订单产品是否已经BOM初始化子件情况了
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                    if (dr != null)
                    {
                        if (MaterialBOMManage.IsExistBOMByMaterialGuid(dr["MaterialGuID"].ToString()) == false)
                        {
                            IsExistNoBom = true;
                            //strMaterialID = dr["MaterialID"].ToString();
                            //strMaterialName = dr["MaterialName"].ToString();
                        }
                        else
                        {
                            IsExistBom = true;
                        }


                        if (IsExistBom == true && IsExistNoBom == true)
                        {
                            this.Cursor = Cursors.Arrow;
                            this.ShowMessage("有BOM与无BOM的物料不能放在一起进行物料需求计算,请分开后再计算物料需求!");
                            return;
                        }
                    }
                }


                if (IsExistBom == true)
                {
                    //全是BOM的料件计算

                    //删除临时表中待计算的料件
                    MaterialMRPPlanManage.DeleteSelectMaterial(txtMaterialMRPPlanGuid.Text);

                    //先将选择的物料插入到临时表中,参与计算
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                        if (dr != null)
                        {
                            string  strMaterialMRPPlanGuID = txtMaterialMRPPlanGuid.Text;
                            string  strMaterialGuid        = dr["MaterialGuID"].ToString();
                            decimal decMaterialSum         = 0;
                            if (dr["YCMaterialSum"].ToString().Trim() != "")
                            {
                                decMaterialSum = decimal.Parse(dr["YCMaterialSum"].ToString());
                            }

                            MaterialMRPPlanManage.InsertIntoSelectMaterial(strMaterialMRPPlanGuID, strMaterialGuid, decMaterialSum);
                        }
                    }



                    //第一步:将产品折成最后的子件,子件数量
                    MaterialMRPPlanManage.CalcMaterialBomPlan2(txtMaterialMRPPlanGuid.Text);


                    //将半成品与成品折成料件后,得出最后需要采购的料件,最后再反算出库存
                    DataTable dtl = MaterialMRPPlanManage.sp_Calc(txtMaterialMRPPlanGuid.Text);

                    gridControl2.DataSource = dtl;

                    tabControl1.SelectedIndex = 1;
                }
                else
                {
                    //全是非BOM的料件计算
                    //删除临时表中待计算的料件
                    MaterialMRPPlanManage.DeleteSelectMaterial(txtMaterialMRPPlanGuid.Text);

                    //先将选择的物料插入到临时表中,参与计算
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                        if (dr != null)
                        {
                            string  strMaterialMRPPlanGuID = txtMaterialMRPPlanGuid.Text;
                            string  strMaterialGuid        = dr["MaterialGuID"].ToString();
                            decimal decMaterialSum         = 0;
                            if (dr["YCMaterialSum"].ToString().Trim() != "")
                            {
                                decMaterialSum = decimal.Parse(dr["YCMaterialSum"].ToString());
                            }

                            MaterialMRPPlanManage.InsertIntoSelectMaterial(strMaterialMRPPlanGuID, strMaterialGuid, decMaterialSum);
                        }
                    }


                    //将半成品与成品折成料件后,得出最后需要采购的料件,最后再反算出库存
                    DataTable dtl = MaterialMRPPlanManage.sp_Calc_NoBOM(txtMaterialMRPPlanGuid.Text);

                    gridControl2.DataSource = dtl;

                    tabControl1.SelectedIndex = 1;

                    //按物料编号排序
                    gridMaterialIDDetail.SortOrder = ColumnSortOrder.Ascending;
                }

                this.Cursor = Cursors.Arrow;
            }
            catch (Exception err)
            {
                this.ShowMessage("计算出错,信息:" + err.Message);
                this.Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 4
0
        //修改1  增加对BOM层级的领料
        private void btnLevelDrawPlan_Click(object sender, EventArgs e)
        {
            if (cboLevel.Text.Trim() == "")
            {
                this.ShowMessage("请选择层级!");
                cboLevel.Focus();
                return;
            }


            try
            {
                this.Cursor = Cursors.WaitCursor;
                txtRemark.Focus();
                gridView1.UpdateCurrentRow();

                DrawPlanManage    DrawPlanManage    = new DrawPlanManage();
                MaterialBOMManage MaterialBOMManage = new MaterialBOMManage();
                bool   IsExist         = false;
                string strMaterialID   = "";
                string strMaterialName = "";
                //检查此客户订单产品是否已经BOM初始化子件情况了
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                    if (dr != null)
                    {
                        if (MaterialBOMManage.IsExistBOMByMaterialGuid(dr["MaterialGuID"].ToString()) == false)
                        {
                            IsExist         = true;
                            strMaterialID   = dr["MaterialID"].ToString();
                            strMaterialName = dr["MaterialName"].ToString();
                            break;
                        }
                    }
                }

                if (IsExist == true)
                {
                    this.ShowMessage("物料编号:" + strMaterialID + ",名称:" + strMaterialName + " 的料件没有BOM,无法计算!");
                    return;
                }



                //删除临时表中待计算的料件
                DrawPlanManage.DeleteSelectMaterial(txtDrawPlanGuid.Text);

                //先将选择的物料插入到临时表中,参与计算

                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                    if (dr != null)
                    {
                        string  strDrawPlanGuID = txtDrawPlanGuid.Text;
                        string  strMaterialGuid = dr["MaterialGuID"].ToString();
                        decimal decMaterialSum  = 0;
                        if (dr["YCMaterialSum"].ToString().Trim() != "")
                        {
                            decMaterialSum = decimal.Parse(dr["YCMaterialSum"].ToString());
                        }

                        DrawPlanManage.InsertIntoSelectMaterial(strDrawPlanGuID, strMaterialGuid, decMaterialSum);
                    }
                }

                //开始计算
                DataTable dtl = DrawPlanManage.CalcMaterialDrawPlan3(txtDrawPlanGuid.Text, cboLevel.Text.Trim());

                gridControl2.DataSource = dtl;

                tabControl1.SelectedIndex = 1;

                this.Cursor = Cursors.Arrow;
            }
            catch (Exception err)
            {
                this.ShowMessage("计算出错,信息:" + err.Message);
                this.Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 5
0
        private void btnSelectDrawPlan_Click_1(object sender, EventArgs e)
        {
            frmSelectDrawPlan frmSelectDrawPlan = new frmSelectDrawPlan();

            frmSelectDrawPlan.ShowDialog();

            if (frmSelectDrawPlan.Tag != null)
            {
                //得到选中的物料需求计划物料数据信息
                List <String> list = new List <string>();
                list = (List <String>)frmSelectDrawPlan.Tag;


                //得到客户订单的明细数据,组件sql
                if (list.Count > 0)
                {
                    DataTable dtl = new DataTable();
                    if (list[1].Trim() == "")
                    {
                        dtl = DrawPlanManage.GetDrawPlanCalcSumByDrawPlanGuid(list[0]);
                    }
                    else
                    {
                        dtl = DrawPlanManage.GetDrawPlanCalcSumByDrawPlanGuid(list[0], list[1]);
                    }


                    //得到当前成品的Guid
                    MaterialBOMManage MaterialBOMManage      = new MaterialBOMManage();
                    string            strProductMaterialGuid = DrawPlanManage.GetDrawPlanFatherMaterialGuid(list[0].Trim());

                    //执行得到产品下面的子件数据记录
                    dsConsume = MaterialBOMManage.sp_GetMaterialBomConsume(strProductMaterialGuid);


                    //填充数据
                    for (int j = 0; j < dtl.Rows.Count; j++)
                    {
                        //将选择的客户订单的数据加载过来
                        //填充数据
                        gridView1.AddNewRow();
                        gridView1.SetFocusedRowCellValue(gridMaterialGuID, dtl.Rows[j]["MaterialGuID"].ToString());
                        gridView1.SetFocusedRowCellValue(gridMaterialID, dtl.Rows[j]["MaterialID"].ToString());
                        gridView1.SetFocusedRowCellValue(gridMaterialName, dtl.Rows[j]["MaterialName"].ToString());
                        gridView1.SetFocusedRowCellValue(gridUnit, dtl.Rows[j]["Unit"].ToString());
                        gridView1.SetFocusedRowCellValue(gridSpec, dtl.Rows[j]["Spec"].ToString());
                        gridView1.SetFocusedRowCellValue(gridMaterialSum, "0");


                        gridView1.SetFocusedRowCellValue(gridApplyMaterialSum, decimal.Parse(dtl.Rows[j]["RequirementSum"].ToString()).ToString("g0"));

                        if (GetFieldDataValue(dtl.Rows[j]["MaterialGuID"].ToString()).Trim() != "")
                        {
                            gridView1.SetFocusedRowCellValue(gridConsumeSum, decimal.Parse(GetFieldDataValue(dtl.Rows[j]["MaterialGuID"].ToString())).ToString("g0"));
                        }
                        else
                        {
                            gridView1.SetFocusedRowCellValue(gridConsumeSum, "0");
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void btnAddDetail_Click(object sender, EventArgs e)
        {
            MaterialBOMManage MaterialBOMManage = new MaterialBOMManage();

            frmSelectMaterial2 frmSelectMaterial2 = new frmSelectMaterial2();

            frmSelectMaterial2.ShowDialog();

            if (frmSelectMaterial2.Tag != null)
            {
                //取出选择的料件Guid
                List <string> lstGuid = frmSelectMaterial2.Tag as List <string>;

                //选择的品名填充
                if (lstGuid.Count > 0)
                {
                    //组建物料sql
                    string strsql = " where 1<>1 ";
                    for (int i = 0; i < lstGuid.Count; i++)
                    {
                        strsql = strsql + " or MaterialGuid='" + lstGuid[i] + "'";
                    }

                    //加载单耗
                    DataSet dsetConsume = new DataSet();
                    if (frmSelectMaterial2.txtQryValue.Text.Trim() != "")
                    {
                        if (frmSelectMaterial2.txtQryValue.Tag != null)
                        {
                            //确认是点击了BOM查询
                            dsetConsume = MaterialBOMManage.sp_GetMaterialBomConsumeByDrawOrder(strsql, frmSelectMaterial2.txtQryValue.Tag.ToString());
                        }
                    }

                    //得到料件的信息
                    for (int i = 0; i < lstGuid.Count; i++)
                    {
                        Material material = new Material();
                        material = MaterialManage.GetMaterialByGuid(lstGuid[i]);

                        //填充数据
                        gridView1.AddNewRow();
                        gridView1.SetFocusedRowCellValue(gridMaterialGuID, material.MaterialGuID);
                        gridView1.SetFocusedRowCellValue(gridMaterialID, material.MaterialID);
                        gridView1.SetFocusedRowCellValue(gridMaterialName, material.MaterialName);
                        gridView1.SetFocusedRowCellValue(gridUnit, base.GetBasicDataNameByID(material.Unit));
                        gridView1.SetFocusedRowCellValue(gridSpec, base.GetBasicDataNameByID(material.Spec));

                        //加载单耗
                        if (frmSelectMaterial2.txtQryValue.Text.Trim() != "")
                        {
                            if (frmSelectMaterial2.txtQryValue.Tag != null)
                            {
                                decimal decConsumeSum = GetConsumeSum(material.MaterialGuID, dsetConsume);

                                gridView1.SetFocusedRowCellValue(gridConsumeSum, decConsumeSum.ToString("g0"));
                            }
                        }
                    }
                }
            }
        }