Пример #1
0
        //窗体载入(Load)事件方法
        private void WorkOrderMatRetListCtrl_Load(object sender, EventArgs e)
        {
            //1、通过PropertyService获取PROPERTY_FIELDS.STORES的值。
            string strStore = PropertyService.Get(PROPERTY_FIELDS.STORES);
            //2、通过PropertyService获取PROPERTY_FIELDS.OPERTIONS的值。
            string strOperation = PropertyService.Get(PROPERTY_FIELDS.OPERATIONS);

            //3、根据步骤1获取的线上仓名称和步骤2获取的工序名称从WST_TL_ZMMLPO,WST_TL_ZMMLKO,WST_STORE_MATERIAL_DETAIL,WST_STORE_MATERIAL,WST_STORE分页获取数据显示到列表中(每页默认为20行记录)。
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();
            DataSet ds = wOMaterialReturnEntity.GetRetMatInfo(strStore, strOperation);

            Content.MainView   = gvWoRetMatList;
            Content.DataSource = ds.Tables[0];
            gvWoRetMatList.BestFitColumns();
        }
Пример #2
0
        //捞起当前时间的班别,并且绑定数据
        public void BindingCurrentShift()
        {
            DataTable dt = new DataTable();
            //调用实体的方法GetCurrentShift
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();

            dt = wOMaterialReturnEntity.GetCurrentShift().Tables[0];
            try
            {
                lueShiftName.EditValue = dt.Rows[0]["SHIFT"].ToString().Trim();
                lueShiftName.Enabled   = false;
            }
            finally
            {
            }
        }
Пример #3
0
        //生成单号
        private string CreateReturnMatNo()
        {
            string strRetMatNo = null;
            //厂别
            DataView  dvMatLotList = gvMaterialList.DataSource as DataView;
            DataTable dtMatLotList = dvMatLotList.Table;
            string    strFacRoom   = dtMatLotList.Rows[0]["FACROOM"].ToString();//工厂车间
            //调用实体方法
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();
            DataSet dsFactory = wOMaterialReturnEntity.GetFacRoomtoFac(strFacRoom);

            string strFactory = dsFactory.Tables[0].Rows[0]["FACTORY"].ToString();
            string tmpFacCode = GetFromMESFacToERPLine(strFactory);

            //4.2 年月日
            string tmpYYMD = GetYYMD();

            //4.3流水码
            string strPrex = tmpFacCode + tmpYYMD;
            // WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();
            DataSet dsMaxRetMatNo = wOMaterialReturnEntity.GetRetMatNo(strPrex);
            string  strNum        = "00000";

            if (dsMaxRetMatNo.Tables[0].Rows.Count < 1)
            {
                strNum = "00001";
            }
            else
            {
                int itmpNum = int.Parse(dsMaxRetMatNo.Tables[0].Rows[0]["SERIALNO"].ToString());
                itmpNum = itmpNum + 1;
                strNum  = string.Format("{0:D5}", itmpNum);
            }
            //退料单号
            strRetMatNo = strPrex + strNum;
            return(strRetMatNo);
        }
Пример #4
0
        //退料清单列表行DoubleClick事件方法
        private void Content_DoubleClick(object sender, EventArgs e)
        {
            //1、将该行对应的退料单传递给工单退料界面(界面一)
            int       i             = gvWoRetMatList.FocusedRowHandle;
            DataView  dv            = gvWoRetMatList.DataSource as DataView;
            DataTable dt            = dv.Table;
            string    strRetMatList = dt.Rows[i]["RETURNNO"].ToString(); //一个参数
            //2、根据退料单号从WST_TL_ZMMLKO,WST_TL_ZMMLPO,WST_STORE_MATERIAL_DETAIL,WST_STORE_MATERIAL获取退料信息。
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();
            DataSet ds = wOMaterialReturnEntity.GetRetMatInfo1(strRetMatList);    //两个参数

            //3、如果没有获取到退料单号对应的退料信息,提示“退料单不存在。“,退出方法执行。
            if (ds.Tables[0].Rows.Count < 1)
            {
                MessageBox.Show("退料单不存在");
            }
            //4、将退料单信息显示在工单退料界面中(界面一),禁用保存,移除按钮。设置退料日期,退库数量为只读。
            bool savefalse       = false;
            bool movedeletefalse = false;
            bool newtrue         = true;

            this.parent.parent2.tiaoyong(ds, strRetMatList, savefalse, movedeletefalse, newtrue);
            WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.CloseWindow(true);
        }
Пример #5
0
        //”确定“按钮Click事件方法
        private void cmdOK_Click(object sender, EventArgs e)
        {
            //1、根据物料批号(左匹配模糊查询),物料编码(左匹配模糊查询),物料描述(左匹配模糊查询),工序名称,线上仓名称,工厂车间,设备名称,
            //供应商(左匹配模糊查询),班次,员工号(左匹配模糊查询),退料单号
            //退料日期区间从WST_TL_ZMMLKO,WST_TL_ZMMLPO,WST_STORE_MATERIAL_DETAIL,WST_STORE_MATERIAL分页获取数据(每页默认为20行记录)。
            //2、若工序名称为空以PROPERTY_FIELDS.OPERATIONS的值作为工序名称的查询条件,若线上仓名称为空以PROPERTY_FIELDS.STORES的值作为线上仓名称的查询条件,
            //若其他窗体栏位值为空,则不作为查询条件。
            string strMatLot       = txtEMatLot.Text;
            string strMatCode      = txtEMatCode.Text;
            string strMatDes       = txtEMatDes.Text;
            string strOperation    = cmbBEOperation.Text;
            string strStore        = cmbBEStore.Text;
            string strFacRoom      = cmbBERoom.Text;
            string strSupplier     = txtEsupplier.Text;
            string strShift        = cmbBEShift.Text;
            string strOperator     = txtEOperator.Text;
            string strFromRetDate  = dateEStart.Text;
            string strToRetDate    = dateEEnd.Text;
            string strRetMatNo     = txtERetMatNo.Text;//1
            string strOperationALL = PropertyService.Get(PROPERTY_FIELDS.OPERATIONS);
            string strStoreALL     = PropertyService.Get(PROPERTY_FIELDS.STORES);
            WOMaterialReturnEntity OMaterialReturnEntity = new WOMaterialReturnEntity();
            DataSet dsWoRetMatInof = OMaterialReturnEntity.GetWoRetMatInof(strMatLot, strMatCode, strMatDes,
                                                                           strOperation, strStore, strFacRoom, strSupplier, strShift, strOperator, strFromRetDate, strToRetDate, strRetMatNo,
                                                                           strOperationALL, strStoreALL);

            // DataSet GetWoRetMatInof(string strMatLot,string strMatCode,string strMatDes,string strOperation ,string strStore,string strFacRoom, string strSupplier,string strShift,string strOperator,string strFromRetDate   ,string strToRetMat );

            //"3、将步骤1获取的数据显示到界面二的列表中(每页默认为20行记录)。
            //调用显示类的方法,传递dataset
            this.ParentControl.bangding(dsWoRetMatInof);

            //4、关闭查询对话框。
            this.Close();
            //5、若程序执行出错,则给出对应的错误提示。"
        }
Пример #6
0
        //删除    ,代表不退库了,要加上去在物料明细中
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            //1、如果退料单号为空,则提示”退料单号为空,不能删除。“。,退出方法执行。
            if (lcBaseInfo.Text == "")
            {
                MessageBox.Show("退料单号为空,不能删除");
                return;
            }

            //2、退料单号不为空,根据退料单号,调用SAP RFC接口判断SAP中的退料单是否删除?
            DataSet   dsIMPORT = new DataSet();
            DataTable dtIMPORT = new DataTable();

            dtIMPORT.Columns.Add("I_WERKS");
            dtIMPORT.Columns.Add("I_DATB");
            dtIMPORT.Columns.Add("I_DATE");
            dtIMPORT.Columns.Add("I_STAT");
            dtIMPORT.Columns.Add("I_TYP");
            dtIMPORT.Columns.Add("I_ART");
            DataRow drIMPORT = dtIMPORT.NewRow();

            drIMPORT["I_WERKS"] = "";   //ERP的工厂
            drIMPORT["I_DATB"]  = "";   //不知道
            drIMPORT["I_DATE"]  = "";
            drIMPORT["I_STAT"]  = "";
            drIMPORT["I_TYP"]   = "";
            drIMPORT["I_ART"]   = "";
            dtIMPORT.Rows.Add(drIMPORT);
            dsIMPORT.Tables.Add(dtIMPORT);

            //I_WERKS        type     WERKS_D           工厂
            //I_DATB         type     DATS              创建日期—起始
            //I_DATE         type     DATS              创建日期—终止
            //I_STAT         type     ZMMAPRED          单据状态
            //I_TYP          type     ZMMTYP            订单类别
            //I_ART          type     ZMMART            订单类型

            bool bltmp  = false; //true代表删除,flase 代表没有删除
            bool bltmp2 = false; //SAP已经删除,删除退料表示是否出错
            //判断SAP是否删除
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();

            bltmp = wOMaterialReturnEntity.DeleteMat(dsIMPORT);

            //3、如果SAP中退料单已删除,则从WST_TL_ZMMLKO,WST_TL_ZMMLPO删除退料单号对应的退料单记录,更新明细
            if (bltmp == true)//删除了
            {
                bltmp2 = wOMaterialReturnEntity.DeleteMat2(txtReturnNo.Text);
                if (bltmp2 == true)
                {
                    MessageBox.Show("删除成功");
                }
                else
                {
                    MessageBox.Show("删除失败,请检查以后重新删除");
                }
            }
            //4、如果SAP中退料单未删除,则提示用户”需要SAP中删除该退料单后,才能执行删除。“。
            else if (bltmp == false)//没有删除
            {
                MessageBox.Show("需要SAP中删除该退料单后,才能执行删除。");
                return;
            }
        }
Пример #7
0
        //“保存”按钮的Click事件方法。
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (gvMaterialList.State == GridState.Editing && gvMaterialList.IsEditorFocused &&
                gvMaterialList.EditingValueModified)
            {
                gvMaterialList.SetFocusedRowCellValue(gvMaterialList.FocusedColumn, gvMaterialList.EditingValue);
            }
            this.gvMaterialList.UpdateCurrentRow();

            gvMaterialList.RefreshData();
            gcMaterialList.Refresh();
            //1、判断退料日期、退料班别、员工号是否为空,如果为空,给出提示,退出方法执行。
            if (deReturnMatDate.Text == "" || lueShiftName.Text == "" || txtOperator.Text == "")
            {
                MessageBox.Show("退料日期,退料班别,员工号有为空的,三个都不能为空才可以保存");
                return;
            }

            //2、判断物料明细列表中的记录是否>0,如果不大于0,则给出提示”物料明细中必须有一条记录。“,退出方法执行。
            if (gvMaterialList.DataRowCount < 1)
            {
                MessageBox.Show("物料明细中必须有一条记录");
                return;
            }

            //3、判断物料明细列表中物料的退库数量是否>数据库中该物料的当前数量,如果是,则给出提示”物料:{物料批号}的退库数量大于当前数量。“,退出方法执行。
            //gvMaterialList.
            DataView  dvMatLotList = gvMaterialList.DataSource as DataView;
            DataTable dtMatLotList = dvMatLotList.Table;

            for (int i = 0; i < dtMatLotList.Rows.Count; i++)
            {
                if (float.Parse(dtMatLotList.Rows[i]["RETURNQTY"].ToString()) > float.Parse(dtMatLotList.Rows[i]["CURRENTQTY"].ToString()))
                {
                    // string tmpMatLot=dtMatList.Rows[i]["MaterialLot"].ToString();
                    MessageBox.Show("物料批号" + dtMatLotList.Rows[i]["MATLOT"].ToString() + "退库数量大于当前数量");
                    return;
                }
            }
            //modify by qym 20120408
            for (int i = 0; i < dtMatLotList.Rows.Count; i++)
            {
                if (int.Parse(dtMatLotList.Rows[i]["RETURNQTY"].ToString()) == 0)
                {
                    MessageBox.Show("物料批号" + dtMatLotList.Rows[i]["MATLOT"].ToString() + "退库数量为0,请输入一个大于0的数");
                    return;
                }
            }
            //modify by qym 20120408
            if (txtReturnMatReason.Text.Trim().Length == 0)
            {
                MessageBox.Show("退料原因为空,请填写退料原因");
                return;
            }


            //4、向WST_TL_ZMMLKO,WST_TL_ZMMLPO插入退料记录。根据规则生成退料单号。
            //5、更新WST_STORE_MATERIAL_DETAIL物料批号对应物料的当前数量=当前数量-退库数量。
            //6、调用SAP RFC将退料单写到SAP中。
            string strRetMatNo = CreateReturnMatNo();                                           //生成退料单

            string strRetMatDate   = String.Format("{0:yyyy-MM-dd}", deReturnMatDate.DateTime); //退库日期
            string strShift        = lueShiftName.Text;                                         //班别
            string strOperator     = txtOperator.Text;                                          //作业员
            string strRetMatReason = txtReturnMatReason.Text;                                   //退料原因

            bool tmpbool = false;
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();

            tmpbool = wOMaterialReturnEntity.Save(strRetMatNo, strRetMatDate, strShift, strOperator, strRetMatReason, dtMatLotList);

            //7、生成退料单成功,提示"退料成功。”,将退料单号显示在控件中,禁用保存,移除按钮。设置退料日期,退库数量为只读。
            if (tmpbool == true)
            {
                MessageBox.Show("退料成功");
                txtReturnNo.Text          = strRetMatNo;
                tsbSave.Enabled           = false;
                btnRemoveMaterial.Enabled = false;
                //设置退料日期
                //退库数量为只读
                gcReturnQty.OptionsColumn.AllowEdit = false;
                //保存成功以后显示保存信息,不能随便修改。
                txtMaterialLot.Enabled     = false;
                txtReturnMatReason.Enabled = false;
            }
            //8、如果执行中失败,给出错误提示。
            else
            {
                MessageBox.Show("退料失败");
            }
        }
Пример #8
0
        //物料批号KeyPress事件方法
        private void txtMaterialLot_KeyPress(object sender, KeyPressEventArgs e)
        {
            //1、如果不是回车按钮,退出方法执行。
            if (e.KeyChar != 13)
            {
                return;
            }

            //2、如果是回车按钮,根据输入的物料批号从WST_STORE_MATERIAL_DETAIL,WST_STORE_MATERIAL获取物品批号对应的物料信息。
            if (txtMaterialLot.Text.Trim().Length == 0)
            {
                MessageBox.Show("输入的物料批号为空,请重新输入");
                return;
            }
            //调用实体的方法GetMatLotInfo
            WOMaterialReturnEntity wOMaterialReturnEntity = new WOMaterialReturnEntity();
            DataSet dsMatLotInfo = wOMaterialReturnEntity.GetMatLotInfo(txtMaterialLot.Text.Trim());

            //判断查询结果有数据吗
            if (dsMatLotInfo.Tables[0].Rows.Count < 1)
            {
                MessageBox.Show("这个LOT不存在");
                return;
            }

            //3、判断物料是否存在,如果不存在,给出提示,“物料批号对应的物料不存在。
            for (int i = 0; i < dsMatLotInfo.Tables[0].Rows.Count; i++)
            {
                if (dsMatLotInfo.Tables[0].Rows[i]["MATCODE"].ToString().Length == 0)
                {
                    MessageBox.Show("物料批号对应的物料编码(料号)不存在");
                    return;
                }
            }

            //4、判断物料所在线上仓是否是登录用户拥有权限的线上仓。如果不是,给出提示“您没有操作物料所在线上仓的权限,不能进行退料。”,退出方法执行。
            string strStore = PropertyService.Get(PROPERTY_FIELDS.STORES);//得到了用户所有的线上仓
            bool   blTmpFlg = false;

            if (strStore.Length <= 0)
            {
                blTmpFlg = false;
            }
            else
            {
                blTmpFlg = true;
            }
            Dictionary <int, bool> blTmpFlg2 = new Dictionary <int, bool>();

            if (blTmpFlg == true)
            {
                string[] strArrStore = strStore.Split(',');
                for (int j = 0; j < dsMatLotInfo.Tables[0].Rows.Count; j++)
                {
                    blTmpFlg2.Add(j, false);
                    for (int i = 0; i < strArrStore.Length; i++)
                    {
                        if (strArrStore[i] == dsMatLotInfo.Tables[0].Rows[j]["STORE"].ToString())
                        {
                            blTmpFlg2.Remove(j);
                            blTmpFlg2.Add(j, true);
                            break;
                        }
                    }
                }
            }

            if (blTmpFlg == false || blTmpFlg2.ContainsValue(false))
            {
                MessageBox.Show("您没有操作物料所在线上仓的权限,不能进行退料。");
                return;
            }

            //5、判断物料所在工序是否是登录用户拥有权限的工序,如果不是,给出提示“您没有操作物料所在工序的权限,不能进行退料。”,退出方法执行。
            string stroperation = PropertyService.Get(PROPERTY_FIELDS.OPERATIONS);

            blTmpFlg = false;
            blTmpFlg2.Clear();
            if (stroperation.Length <= 0)
            {
                blTmpFlg = false;
            }
            else
            {
                blTmpFlg = true;
            }
            if (blTmpFlg == true)
            {
                string[] strarroperation = stroperation.Split(',');
                for (int j = 0; j < dsMatLotInfo.Tables[0].Rows.Count; j++)
                {
                    blTmpFlg2.Add(j, false);
                    for (int i = 0; i < strarroperation.Length; i++)
                    {
                        if (strarroperation[i] == dsMatLotInfo.Tables[0].Rows[j]["OPERATION"].ToString())
                        {
                            blTmpFlg2.Remove(j);
                            blTmpFlg2.Add(j, true);
                            break;
                        }
                    }
                }
            }

            if (blTmpFlg == false || blTmpFlg2.ContainsValue(false))
            {
                MessageBox.Show("您没有操作物料所在工序的权限,不能进行退料。");
                return;
            }
            //6、判断物料当前数量是否是0,如果是,给出提示”当前物料批次对应的物料数量为0,不能进行退料。”,退出方法执行。
            for (int j = 0; j < dsMatLotInfo.Tables[0].Rows.Count; j++)
            {
                if (int.Parse(dsMatLotInfo.Tables[0].Rows[j]["CURRENTQTY"].ToString().Trim()) == 0)
                {
                    MessageBox.Show("当前物料批次对应的物料数量为0,不能进行退料");
                    return;
                }
            }
            DataTable dtMatLotInfo = dsMatLotInfo.Tables[0];
            DataView  dv           = this.gvMaterialList.DataSource as DataView;

            if (!(dv == null))
            {
                for (int i = 0; i < dv.Table.Rows.Count; i++)
                {
                    if (txtMaterialLot.Text == dv.Table.Rows[i]["MATLOT"].ToString())
                    {
                        MessageBox.Show("批次重复了");
                        return;
                    }
                }
            }

            for (int j = 0; j < dsMatLotInfo.Tables[0].Rows.Count; j++)
            {
                dv = this.gvMaterialList.DataSource as DataView;
                if (dv == null)
                {
                    DataTable dttemp = new DataTable();
                    dttemp.Columns.Add("INDEX");
                    dttemp.Columns.Add("MATLOT");
                    dttemp.Columns.Add("MATCODE");
                    dttemp.Columns.Add("MATDES");

                    dttemp.Columns.Add("WORKORDERNO");
                    dttemp.Columns.Add("UNIT");
                    dttemp.Columns.Add("CURRENTQTY");

                    dttemp.Columns.Add("RETURNQTY");
                    dttemp.Columns.Add("SUPPLIER");

                    dttemp.Columns.Add("OPERATION");
                    dttemp.Columns.Add("STORE");
                    dttemp.Columns.Add("FACROOM");

                    DataRow drtemp = dttemp.NewRow();
                    drtemp["INDEX"]   = 1;
                    drtemp["MATLOT"]  = dtMatLotInfo.Rows[j]["MATLOT"];
                    drtemp["MATCODE"] = dtMatLotInfo.Rows[j]["MATCODE"];
                    drtemp["MATDES"]  = dtMatLotInfo.Rows[j]["MATDES"];

                    drtemp["WORKORDERNO"] = dtMatLotInfo.Rows[j]["WORKORDERNO"];
                    drtemp["UNIT"]        = dtMatLotInfo.Rows[j]["UNIT"];
                    drtemp["CURRENTQTY"]  = dtMatLotInfo.Rows[j]["CURRENTQTY"];

                    drtemp["RETURNQTY"] = dtMatLotInfo.Rows[j]["RETURNQTY"];
                    drtemp["SUPPLIER"]  = dtMatLotInfo.Rows[j]["SUPPLIER"];

                    drtemp["OPERATION"] = dtMatLotInfo.Rows[j]["OPERATION"];
                    drtemp["STORE"]     = dtMatLotInfo.Rows[j]["STORE"];
                    drtemp["FACROOM"]   = dtMatLotInfo.Rows[j]["FACROOM"];
                    dttemp.Rows.Add(drtemp);
                    gcMaterialList.DataSource = dttemp;
                    gcMaterialList.RefreshDataSource();
                }
                else if (dv != null)//判断转换成功没
                {
                    DataTable dt = dv.Table;
                    DataRow   dr = dt.NewRow();
                    dr["INDEX"]   = dt.Rows.Count + 1;
                    dr["MATLOT"]  = dtMatLotInfo.Rows[j]["MATLOT"];
                    dr["MATCODE"] = dtMatLotInfo.Rows[j]["MATCODE"];
                    dr["MATDES"]  = dtMatLotInfo.Rows[j]["MATDES"];

                    dr["WORKORDERNO"] = dtMatLotInfo.Rows[j]["WORKORDERNO"];
                    dr["UNIT"]        = dtMatLotInfo.Rows[j]["UNIT"];
                    dr["CURRENTQTY"]  = dtMatLotInfo.Rows[j]["CURRENTQTY"];

                    dr["RETURNQTY"] = dtMatLotInfo.Rows[j]["RETURNQTY"];
                    dr["SUPPLIER"]  = dtMatLotInfo.Rows[j]["SUPPLIER"];

                    dr["OPERATION"] = dtMatLotInfo.Rows[j]["OPERATION"];
                    dr["STORE"]     = dtMatLotInfo.Rows[j]["STORE"];
                    dr["FACROOM"]   = dtMatLotInfo.Rows[j]["FACROOM"];
                    dt.Rows.Add(dr);
                }
            }

            this.gvMaterialList.RefreshData();
            gvMaterialList.BestFitColumns();
            txtMaterialLot.Text = "";
        }