protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (ddlSubAssetCategory.SelectedIndex < 0)
     {
         UIHelper.Alert(this.UpdatePanel1, "请添加设备分类信息!");
         return;
     }
     var detailInfo = ProcurementContractDetail.Where(p => p.Contractdetailid == Detailid).FirstOrDefault();
     if (detailInfo == null)
     {
         detailInfo = new Procurementcontractdetail();
         ProcurementContractDetail.Add(detailInfo);
         detailInfo.Contractdetailid = Guid.NewGuid().ToString("N");
     }
     WriteControlValueToEntity(detailInfo);
     if (detailInfo.Unitprice <= 0)
     {
         UIHelper.Alert(this.UpdatePanel1, "单价不能小于等于0!");
         return;
     }
     if (detailInfo.Procurenumber <= 0)
     {
         UIHelper.Alert(this.UpdatePanel1, "采购数量不能小于等于0!");
         return;
     }
     ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString("N"), "setCookie('dialogReturn_key','1',1);CloseTopDialogFrame();", true);
 }
 public Procurementcontractdetail CreateProcurementcontractdetail(Procurementcontractdetail info)
 {
     try
     {
         Management.BeginTransaction();
         Management.CreateProcurementcontractdetail(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }
        public Procurementcontractdetail CreateProcurementcontractdetail(Procurementcontractdetail info)
        {
            try
            {
                string sqlCommand = @"INSERT INTO ""PROCUREMENTCONTRACTDETAIL"" (""CONTRACTDETAILID"",""CONTRACTID"",""ASSETCATEGORYID"",""ASSETNAME"",""ASSETSPECIFICATION"",""UNITPRICE"",""PROCURENUMBER"",""INPUTNUMBER"",""PSDETAILID"",""PSID"") VALUES (:Contractdetailid,:Contractid,:Assetcategoryid,:Assetname,:Assetspecification,:Unitprice,:Procurenumber,:Inputnumber,:Psdetailid,:Psid)";
                this.Database.AddInParameter(":Contractdetailid", info.Contractdetailid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Contractid", info.Contractid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Assetcategoryid", info.Assetcategoryid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Assetname", info.Assetname);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Assetspecification", info.Assetspecification);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Unitprice", info.Unitprice);//DBType:NUMBER
                this.Database.AddInParameter(":Procurenumber", info.Procurenumber);//DBType:NUMBER
                this.Database.AddInParameter(":Inputnumber", info.Inputnumber);//DBType:NUMBER
                this.Database.AddInParameter(":Psdetailid", info.Psdetailid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Psid", info.Psid);//DBType:VARCHAR2
                this.Database.ExecuteNonQuery(sqlCommand);

            }
            finally
            {
                this.Database.ClearParameter();
            }
            return info;
        }
 protected void ucMultiSelectProcurePlans_SelectProcurePlanChange(object sender, EventArgs e)
 {
     List<string> psids = ucMultiSelectProcurePlans.PsIds;
      if (psids != null && psids.Count > 0)
      {
          List<Procurementscheduledetail> procurementscheduledetails = ProcurementscheduledetailService.RetrieveProcurementscheduledetailListByPsid(psids);
          foreach (Procurementscheduledetail procurementscheduledetail in procurementscheduledetails)
          {
              if (ProcurementContractDetail.Where(p => p.Psdetailid == procurementscheduledetail.Detailid).Count() == 0)
              {
                  var contractitem = new Procurementcontractdetail();
                  contractitem.Assetcategoryid = procurementscheduledetail.Assetcategoryid;
                  contractitem.CategoryAllPathName = procurementscheduledetail.CategoryAllPathName;
                  contractitem.Assetname = procurementscheduledetail.Assetname;
                  contractitem.Assetspecification = procurementscheduledetail.Assetspecification;
                  contractitem.Procurenumber = procurementscheduledetail.Plannumber;
                  contractitem.Unitprice = procurementscheduledetail.Unitprice;
                  contractitem.Contractid = litPsid.Text.Trim();
                  contractitem.Contractdetailid = Guid.NewGuid().ToString("N");
                  contractitem.Psdetailid = procurementscheduledetail.Detailid;
                  contractitem.Psid = procurementscheduledetail.Psid;
                  ProcurementContractDetail.Add(contractitem);
              }
          }
      }
      LoadDetailList();
 }
 protected void WriteControlValueToEntity(Procurementcontractdetail detailInfo)
 {
     if (ddlSubAssetCategory.SelectedIndex >= 0)
     { detailInfo.Assetcategoryid = ddlSubAssetCategory.SelectedValue; }
     detailInfo.Assetname = txtAssetname.Text;
     detailInfo.Assetspecification = txtAssetspecification.Text;
     decimal unitprice = 0;
     if (decimal.TryParse(txtUnitprice.Text, out unitprice))
     {
         detailInfo.Unitprice = unitprice;
     }
     decimal plannumber = 0;
     if (decimal.TryParse(txtPlannumber.Text, out plannumber))
     {
         detailInfo.Procurenumber = plannumber;
     }
 }
 protected void ReadEntityToControl(Procurementcontractdetail detailInfo)
 {
     var subCategory = AssetCategories.Where(p => p.Assetcategoryid == detailInfo.Assetcategoryid).FirstOrDefault();
     if (subCategory != null)
     {
         ddlAssetCategory.SelectedValue = subCategory.Assetparentcategoryid;
         LoadSubAssetCategory();
         ddlSubAssetCategory.SelectedValue = detailInfo.Assetcategoryid;
     }
     else
     {
         LoadSubAssetCategory();
     }
     txtAssetname.Text = detailInfo.Assetname;
     txtAssetspecification.Text = detailInfo.Assetspecification;
     txtUnitprice.Text = detailInfo.Unitprice.ToString();
     txtPlannumber.Text = detailInfo.Procurenumber.ToString();
 }