protected void btnSubmit_Click(object sender, EventArgs e) { if(ddlSubAssetCategory.SelectedIndex<0) { UIHelper.Alert(this.UpdatePanel1,"请添加设备分类信息!"); return; } var detailInfo = ProcureScheduleDetails.Where(p => p.Detailid == Detailid).FirstOrDefault(); if (detailInfo == null) { detailInfo = new Procurementscheduledetail(); ProcureScheduleDetails.Add(detailInfo); detailInfo.Detailid = Guid.NewGuid().ToString("N"); } WriteControlValueToEntity(detailInfo); if(detailInfo.Unitprice<=0) { UIHelper.Alert(this.UpdatePanel1, "单价不能小于等于0!"); return; } if (detailInfo.Plannumber <= 0) { UIHelper.Alert(this.UpdatePanel1, "计划采购数量不能小于等于0!"); return; } ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString("N"), "setCookie('dialogReturn_key','1',1);CloseTopDialogFrame();",true); }
public Procurementscheduledetail CreateProcurementscheduledetail(Procurementscheduledetail info) { try { Management.BeginTransaction(); Management.CreateProcurementscheduledetail(info); Management.Commit(); } catch { Management.Rollback(); throw; } return info; }
public Procurementscheduledetail CreateProcurementscheduledetail(Procurementscheduledetail info) { try { string sqlCommand = @"INSERT INTO ""PROCUREMENTSCHEDULEDETAIL"" (""DETAILID"",""ASSETCATEGORYID"",""ASSETNAME"",""ASSETSPECIFICATION"",""UNITPRICE"",""PLANNUMBER"",""PSID"") VALUES (:Detailid,:Assetcategoryid,:Assetname,:Assetspecification,:Unitprice,:Plannumber,:Psid)"; this.Database.AddInParameter(":Detailid", info.Detailid);//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(":Plannumber", info.Plannumber);//DBType:NUMBER this.Database.AddInParameter(":Psid", info.Psid);//DBType:VARCHAR2 this.Database.ExecuteNonQuery(sqlCommand); } finally { this.Database.ClearParameter(); } return info; }
protected void WriteControlValueToEntity(Procurementscheduledetail 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.Plannumber = plannumber; } }
protected void ReadEntityToControl(Procurementscheduledetail 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.Plannumber.ToString(); }