Ejemplo n.º 1
0
        protected override object GetEditObject()
        {
            if (_facade == null)
            {
                _facade = new MaterialFacade(this.DataProvider);
            }
            DBDateTime    dBDateTime    = FormatHelper.GetNowDBDateTime(this.DataProvider);
            MaterialIssue materialIssue = this._facade.CreateNewMaterialIssue();

            materialIssue.PlanDate     = FormatHelper.TODateInt(this.txtPlanDateFromQuery.Text);
            materialIssue.BigSSCode    = FormatHelper.CleanString(this.txtBigSSCodeGroupQuery.Text.Trim().ToUpper());
            materialIssue.MoCode       = FormatHelper.CleanString(this.txtMoQuery.Text.Trim().ToUpper());
            materialIssue.MoSeq        = Convert.ToDecimal(this.txtMOSeqQuery.Text.Trim());
            materialIssue.IssueSEQ     = _facade.GetMaterialIssueMaxIssueSEQ(materialIssue.BigSSCode, materialIssue.PlanDate, materialIssue.MoCode, materialIssue.MoSeq);
            materialIssue.IssueQTY     = Convert.ToDecimal(this.txtRationNumberEdit.Text);
            materialIssue.IssueType    = MaterialIssueType.MaterialIssueType_Issue;
            materialIssue.IssueStatus  = MaterialIssueStatus.MaterialIssueStatus_Delivered;
            materialIssue.MaintainUser = this.GetUserCode();
            materialIssue.MaintainDate = dBDateTime.DBDate;
            materialIssue.MaintainTime = dBDateTime.DBTime;

            return(materialIssue);
        }
Ejemplo n.º 2
0
        protected void cmdSaveTotal_ServerClick(object sender, EventArgs e)
        {
            if (_facade == null)
            {
                _facade = new MaterialFacade(this.DataProvider);
            }

            if (this.gridHelper.GetCheckedRows().Count < 1)
            {
                WebInfoPublish.PublishInfo(this, "$CS_GRID_SELECT_ONE_RECORD", this.languageComponent1);
                return;
            }

            if (!CheckGridValue())
            {
                return;
            }

            ArrayList  rowList             = this.gridHelper.GetCheckedRows();
            decimal    materialTransNumber = 0;
            DBDateTime dBDateTime          = FormatHelper.GetNowDBDateTime(this.DataProvider);

            try
            {
                this.DataProvider.BeginTransaction();

                foreach (UltraGridRow row in rowList)
                {
                    //更新的oldWorkPlan的MaterialQty
                    WorkPlan oldWorkPlan = (WorkPlan)_facade.GetWorkPlan(row.Cells[2].Text.Trim(),
                                                                         Convert.ToInt32(row.Cells[1].Text),
                                                                         row.Cells[4].Text.Trim(),
                                                                         Convert.ToDecimal(row.Cells[5].Text.Trim()));
                    if (oldWorkPlan != null)
                    {
                        oldWorkPlan.MaterialQty = oldWorkPlan.MaterialQty - Convert.ToDecimal(row.Cells[11].Text.Trim());
                    }

                    _facade.UpdateWorkPlan(oldWorkPlan);
                    //end

                    //新增转出Trans
                    MaterialIssue newOutMaterialIssue = new MaterialIssue();

                    newOutMaterialIssue.BigSSCode = row.Cells[2].Text.Trim();
                    newOutMaterialIssue.PlanDate  = Convert.ToInt32(row.Cells[1].Text);
                    newOutMaterialIssue.MoCode    = row.Cells[4].Text.Trim();
                    newOutMaterialIssue.MoSeq     = Convert.ToDecimal(row.Cells[5].Text.Trim());
                    newOutMaterialIssue.IssueSEQ  = _facade.GetMaterialIssueMaxIssueSEQ(newOutMaterialIssue.BigSSCode, newOutMaterialIssue.PlanDate,
                                                                                        newOutMaterialIssue.MoCode, newOutMaterialIssue.MoSeq);
                    newOutMaterialIssue.IssueQTY     = Convert.ToDecimal(row.Cells[11].Text.Trim());
                    newOutMaterialIssue.IssueType    = MaterialIssueType.MaterialIssueType_LineTransferOut;
                    newOutMaterialIssue.IssueStatus  = MaterialIssueStatus.MaterialIssueStatus_Close;
                    newOutMaterialIssue.MaintainUser = this.GetUserCode();
                    newOutMaterialIssue.MaintainDate = dBDateTime.DBDate;
                    newOutMaterialIssue.MaintainTime = dBDateTime.DBTime;

                    _facade.AddMaterialIssue(newOutMaterialIssue);
                    //end

                    materialTransNumber += Convert.ToDecimal(row.Cells[11].Text.Trim());
                }

                //新增转入Trans
                MaterialIssue newInMaterialIssue = new MaterialIssue();

                newInMaterialIssue.BigSSCode = ViewState["bigSSCode"].ToString();
                newInMaterialIssue.PlanDate  = Convert.ToInt32(ViewState["planDate"].ToString());
                newInMaterialIssue.MoCode    = this.txtMOEdit.Text.Trim().ToUpper();
                newInMaterialIssue.MoSeq     = Convert.ToDecimal(ViewState["moSeq"].ToString());
                newInMaterialIssue.IssueSEQ  = _facade.GetMaterialIssueMaxIssueSEQ(newInMaterialIssue.BigSSCode, newInMaterialIssue.PlanDate,
                                                                                   newInMaterialIssue.MoCode, newInMaterialIssue.MoSeq);
                newInMaterialIssue.IssueQTY     = materialTransNumber;
                newInMaterialIssue.IssueType    = MaterialIssueType.MaterialIssueType_LineTransferIn;
                newInMaterialIssue.IssueStatus  = MaterialIssueStatus.MaterialIssueStatus_Close;
                newInMaterialIssue.MaintainUser = this.GetUserCode();
                newInMaterialIssue.MaintainDate = dBDateTime.DBDate;
                newInMaterialIssue.MaintainTime = dBDateTime.DBTime;

                _facade.AddMaterialIssue(newInMaterialIssue);
                //end

                //更新BigSSCode+MoCode所有的预警信息
                object[] workPlanObjects = _facade.QueryWorkPlan(ViewState["bigSSCode"].ToString(), this.txtMOEdit.Text.Trim().ToUpper());
                if (workPlanObjects != null)
                {
                    for (int j = 0; j < workPlanObjects.Length; j++)
                    {
                        WorkPlan workPlanUpdate = workPlanObjects[j] as WorkPlan;

                        //更新当前项次的数量
                        if (workPlanUpdate.PlanDate == Convert.ToInt32(ViewState["planDate"].ToString()) &&
                            workPlanUpdate.MoSeq == Convert.ToDecimal(ViewState["moSeq"].ToString()))
                        {
                            workPlanUpdate.MaterialQty += materialTransNumber;
                        }

                        workPlanUpdate.LastReceiveTime = dBDateTime.DBTime;
                        workPlanUpdate.LastReqTime     = 0;
                        workPlanUpdate.PromiseTime     = 0;
                        workPlanUpdate.MaterialStatus  = MaterialWarningStatus.MaterialWarningStatus_No;

                        _facade.UpdateWorkPlan(workPlanUpdate);
                    }
                }

                _facade.UpdateMaterialReqInfo(ViewState["bigSSCode"].ToString(), this.txtMOEdit.Text.Trim().ToUpper());
                //end

                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                WebInfoPublish.Publish(this, ex.Message, this.languageComponent1);
            }

            this.RequestData();
        }