public Procurementschedulehead CreateProcurementschedulehead(Procurementschedulehead info)
        {
            try
            {
                string sqlCommand = @"INSERT INTO ""PROCUREMENTSCHEDULEHEAD"" (""PSID"",""PROCUREMENTSCHEDULEDATE"",""REASON"",""SUBCOMPANY"",""APPLYUSER"",""APPLYDATE"",""APPROVEUSER"",""APPROVEDATE"",""APPROVERESULT"",""REJECTREASON"",""CREATEDDATE"") VALUES (:Psid,:Procurementscheduledate,:Reason,:Subcompany,:Applyuser,:Applydate,:Approveuser,:Approvedate,:Approveresult,:Rejectreason,:Createddate)";
                this.Database.AddInParameter(":Psid", info.Psid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Procurementscheduledate", info.Procurementscheduledate);//DBType:DATE
                this.Database.AddInParameter(":Reason", info.Reason);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Subcompany", info.Subcompany);//DBType:VARCHAR2
                this.Database.AddInParameter(":Applyuser", info.Applyuser);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Applydate", info.Applydate);//DBType:DATE
                this.Database.AddInParameter(":Approveuser", info.Approveuser);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Approvedate", info.Approvedate);//DBType:DATE
                this.Database.AddInParameter(":Approveresult", info.Approveresult);//DBType:INTERVAL YEAR(2) TO MONTH
                this.Database.AddInParameter(":Rejectreason", info.Rejectreason);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Createddate", info.Createddate);//DBType:DATE
                this.Database.ExecuteNonQuery(sqlCommand);

            }
            finally
            {
                this.Database.ClearParameter();
            }
            return info;
        }
 public Procurementschedulehead CreateProcurementschedulehead(Procurementschedulehead info,List<Procurementscheduledetail> detailInfos)
 {
     var coderuleManagement=new CoderuleManagement(Management);
         info.Psid = coderuleManagement.GenerateCodeRule(Procurementschedulehead.RuleCode+DateTime.Today.ToString("yyyyMM"),false);
         foreach (var detailInfo in detailInfos)
         {
             detailInfo.Psid = info.Psid;
         }
         var detailManagement = new ProcurementscheduledetailManagement(Management);
         try
         {
             Management.BeginTransaction();
             Management.CreateProcurementschedulehead(info);
             foreach (var detailInfo in detailInfos)
             {
                 detailManagement.CreateProcurementscheduledetail(detailInfo);
             }
             Management.Commit();
         }
         catch
         {
             Management.Rollback();
             throw;
         }
     return info;
 }
 protected void ReadEntityToControl(Procurementschedulehead headInfo)
 {
     litPsid.Text = headInfo.Psid;
     if (headInfo.Procurementscheduledate.HasValue)
     {
         litProcurementscheduledate.Text = headInfo.Procurementscheduledate.Value.ToString(UiConst.DateFormat);
     }
     litReason.Text = headInfo.Reason;
     ucSubCompany.SubcompanyId = headInfo.Subcompany;
     litApplyuser.Text = headInfo.Applyuser;
     if (headInfo.Applydate.HasValue)
     {
         litApplydate.Text = headInfo.Applydate.Value.ToString(UiConst.DateFormat);
     }
     litApproveuser.Text = headInfo.Approveuser;
     if (headInfo.Approvedate.HasValue)
     {litApprovedate.Text = headInfo.Approvedate.Value.ToString(UiConst.DateFormat);}
     litApproveresult.Text = EnumUtil.RetrieveEnumDescript(headInfo.Approveresult);
     litRejectreason.Text = headInfo.Rejectreason;
     litCreateddate.Text = headInfo.Createddate.Value.ToString(UiConst.DateTimeFormat);
     //if(headInfo.Approveresult==ApproveResult.Approved)
     //{
     //    BtnNewContract.Visible = true;
     //}
 }
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     DateTime dateTime = DateTime.MinValue;
     if (!ucProcurementscheduledate.DateValue.HasValue)
     {
         UIHelper.Alert(this, "请选择计划采购日期!");
         return;
     }
     if (string.IsNullOrEmpty(ucSubCompany.SubcompanyId))
     {
         UIHelper.Alert(this, "请选择分公司!");
         return;
     }
     if (!ucApplydate.DateValue.HasValue)
     {
         UIHelper.Alert(this, "请选择申请日期!");
         return;
     }
     Procurementschedulehead headInfo = null;
     if (string.IsNullOrEmpty(Psid))
     {
         //add
         headInfo = new Procurementschedulehead();
         WriteControlValueToEntity(headInfo);
         this.ProcurementscheduleheadService.CreateProcurementschedulehead(headInfo, ProcureScheduleDetails);
     }
     else
     {
         //edit
         headInfo = ProcurementscheduleheadService.RetrieveProcurementscheduleheadByPsid(Psid);
         if (headInfo == null) { UIHelper.Alert(this, "对不起,计划已被删除,请重新录入!"); return; }
         WriteControlValueToEntity(headInfo);
         headInfo.Approveresult = ApproveResult.Draft;
         ProcurementscheduleheadService.UpdateProcurementscheduleheadByPsid(headInfo, ProcureScheduleDetails);
     }
     UIHelper.AlertMessageGoToURL(this, "保存成功!", ResolveUrl("~/Admin/ProcurePlanList.aspx"));
 }
 protected void WriteControlValueToEntity(Procurementschedulehead headInfo)
 {
     headInfo.Psid = litPsid.Text;
     headInfo.Procurementscheduledate = ucProcurementscheduledate.DateValue;
     headInfo.Reason = txtReason.Text;
     headInfo.Subcompany = ucSubCompany.SubcompanyId;
     headInfo.Applyuser = ucApplyuser.Username;
     headInfo.Applydate = ucApplydate.DateValue;
     if (!headInfo.Createddate.HasValue)
     {
         headInfo.Createddate = DateTime.Now;
     }
 }
 protected void ReadEntityToControl(Procurementschedulehead headInfo)
 {
     litPsid.Text = headInfo.Psid;
     if (headInfo.Procurementscheduledate.HasValue)
     {
         ucProcurementscheduledate.DateValue = headInfo.Procurementscheduledate;
     }
     txtReason.Text = headInfo.Reason;
     ucSubCompany.SubcompanyId = headInfo.Subcompany;
     //txtApplyuser.Text = headInfo.Applyuser;
     //ucApplyuser.Username = headInfo.Applyuser;
     if (headInfo.Applydate.HasValue)
     {
         ucApplydate.DateValue = headInfo.Applydate;
     }
 }
 protected void WriteControlValueToEntity(Procurementschedulehead headInfo)
 {
     headInfo.Rejectreason = string.IsNullOrEmpty(txtRejectreason.Text) ? "无意见" : txtRejectreason.Text;
     headInfo.Approvedate = DateTime.Now;
     if (WebContext.Current.CurrentUser != null)
     {
         headInfo.Approveuser = WebContext.Current.CurrentUser.Username;
     }
 }
 protected void ReadEntityToControl(Procurementschedulehead headInfo)
 {
     litPsid.Text = headInfo.Psid;
     if (headInfo.Procurementscheduledate.HasValue)
     {
         litProcurementscheduledate.Text = headInfo.Procurementscheduledate.Value.ToString(UiConst.DateFormat);
     }
     litReason.Text = headInfo.Reason;
     ucSubCompany.SubcompanyId = headInfo.Subcompany;
     litApplyuser.Text = headInfo.Applyuser;
     if (headInfo.Applydate.HasValue)
     {
         litApplydate.Text = headInfo.Applydate.Value.ToString(UiConst.DateFormat);
     }
 }
 public Procurementschedulehead UpdateProcurementscheduleheadByPsid(Procurementschedulehead info, List<Procurementscheduledetail> detailInfos)
 {
     foreach (var detailInfo in detailInfos)
         {
             detailInfo.Psid = info.Psid;
         }
         var detailManagement = new ProcurementscheduledetailManagement(Management);
         var dbDetails = detailManagement.RetrieveProcurementscheduledetailListByPsid(info.Psid);
         try
         {
             Management.BeginTransaction();
             Management.UpdateProcurementscheduleheadByPsid(info);
             foreach (var detail in detailInfos)
             {
                 var existInfo = dbDetails.Where(p => p.Detailid == detail.Detailid).FirstOrDefault();
                 if (existInfo == null)
                 {
                     detailManagement.CreateProcurementscheduledetail(detail);
                 }
                 else
                 {
                     detailManagement.UpdateProcurementscheduledetailByDetailid(detail);
                 }
             }
             Management.Commit();
         }
         catch
         {
             Management.Rollback();
             throw;
         }
     return info;
 }