protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { InitData(); Contractid = PageUtility.GetQueryStringValue("Contractid"); if (!string.IsNullOrEmpty(Contractid)) { var headInfo = ProcurementcontractService.RetrieveProcurementcontractByContractid(Contractid); if (headInfo != null) { ReadEntityToControl(headInfo); var list = ProcurementcontractdetailService.RetrieveProcurementcontractdetailListByContractid(Contractid); foreach (var contractDetail in list) { if (contractDetail.Procurenumber > contractDetail.Inputnumber) { var data = new ImportAssetContractdetail(); data.Contractdetailid = contractDetail.Contractdetailid; data.Contractid = contractDetail.Contractid; data.Assetcategoryid = contractDetail.Assetcategoryid; data.Assetname = contractDetail.Assetname; data.Assetspecification = contractDetail.Assetspecification; data.Unitprice = contractDetail.Unitprice; data.Procurenumber = contractDetail.Procurenumber; data.ImportNumber = contractDetail.Procurenumber - contractDetail.Inputnumber;//剩下多少可以继续导入设备表 data.Inputnumber = contractDetail.Inputnumber; data.Purchasedate = headInfo.Contractdate;//默认合同签订日 ImportAssetContractdetailContractDetail.Add(data); } } } } LoadDetailList(); } }
protected void WriteControlValueToEntity(ImportAssetContractdetail detailInfo) { //detailInfo.Assetno = txtAssetno.Text;//设备编号 //设备类别 if (ddlSubAssetCategory.SelectedIndex >= 0) { detailInfo.Assetcategoryid = ddlSubAssetCategory.SelectedValue; }; detailInfo.Assetname = txtAssetname.Text;//设备名称 detailInfo.Storageflag =ucSelectStorageAddress.Storagetitle;//存放地点标识来源 detailInfo.Storage = ucSelectStorageAddress.StorageId;//存放地点 //detailInfo.State = state;//设备状态 if(ucPurchasedate.DateValue.HasValue) { detailInfo.Purchasedate = ucPurchasedate.DateValue;//购入日期 } decimal depreciationyear = 0; if (decimal.TryParse(txtDepreciationyear.Text, out depreciationyear)) { detailInfo.Depreciationyear = depreciationyear;//折旧年限 if(detailInfo.Purchasedate.HasValue) { detailInfo.Expireddate = detailInfo.Purchasedate.Value.AddYears((int)depreciationyear);//折旧到期日期 } } decimal unitprice = 0; if (decimal.TryParse(txtUnitprice.Text, out unitprice)) { detailInfo.Unitprice = unitprice;//单价 } detailInfo.Brand = txtBrand.Text;//品牌 decimal plannumber = 0; if (decimal.TryParse(txtPlannumber.Text, out plannumber)) { detailInfo.ImportNumber = plannumber; } detailInfo.Managemode = (ManageMode)Enum.Parse(typeof(ManageMode), ddlManagementModel.SelectedValue);//管理模式 //detailInfo.Financecategory = (FinanceCategory)Enum.Parse(typeof(FinanceCategory), ddlFinancecategory.SelectedValue); //财务类别(A帐:0B帐:1) detailInfo.Assetspecification = txtAssetspecification.Text;//设备规格 //detailInfo.Supplierid = txtSupplierid.Text;//供应商 //detailInfo.Subcompany = txtSubcompany.Text;//分公司 //detailInfo.Contractid = txtContractid.Text;//合同编号 //detailInfo.Contractdetailid = txtContractdetailid.Text;//合同明细编号 }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { InitData(); Instanceid = PageUtility.GetQueryInt64Value("Instanceid",0); if (Instanceid!=0) { var headInfo = HcontractService.RetrieveHcontractByInstanceid(Instanceid); if (headInfo != null) { ReadEntityToControl(headInfo); var list = HcontractService.RetrieveHcontractdetailListByFainstanceid(Instanceid); foreach (var contractDetail in list) { var data = new ImportAssetContractdetail(); data.Contractdetailid = contractDetail.Instanceid.ToString();//合同明细表 data.Contractid = contractDetail.Fainstanceid.ToString();//合同主表 data.Assetcategoryid = contractDetail.Type.ToString();//设备类别 data.Assetname = contractDetail.Detailname; //设备名称 data.Assetspecification = contractDetail.Modal;//设备型号 data.Unitprice = contractDetail.Dj; //单价 data.Procurenumber = contractDetail.Sl;//数量 data.ImportNumber = contractDetail.Sl;//数量 data.Inputnumber = contractDetail.Sl;//数量 data.Purchasedate = headInfo.Htwcrq;//默认合同签订日 ImportAssetContractdetailContractDetail.Add(data); } } } LoadDetailList(); } }
protected void ReadEntityToControl(ImportAssetContractdetail 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.ImportNumber.ToString();//可导入的数量 ucPurchasedate.DateValue = detailInfo.Purchasedate;//购入日 txtBrand.Text = detailInfo.Brand;//品牌 }