public void InitPage() { this.BindDdl(); if (!string.IsNullOrEmpty(this.resourceId)) { this.lblTitle.Text = "编辑资源"; using (pm2Entities entities = new pm2Entities()) { this.hdGuid.Value = this.resourceId; var resource = (from m in entities.Res_Resource where m.ResourceId == this.resourceId select new { Res_Unit = m.Res_Unit, Brand = m.Brand, ResourceCode = m.ResourceCode, ResourceName = m.ResourceName, Specification = m.Specification, TaxRate = m.TaxRate, TechnicalParameter = m.TechnicalParameter, Res_Attribute = m.Res_Attribute, Series = m.Series, ModelNumber = m.ModelNumber, Note = m.Note, SupplierId = m.SupplierId }).First(); this.txtBrand.Text = resource.Brand; this.txtResourceCode.Text = resource.ResourceCode; this.txtResourceName.Text = resource.ResourceName; this.txtSpecification.Text = resource.Specification; this.txtTaxRate.Text = resource.TaxRate.ToString(); this.txtTechnicalParameter.Text = resource.TechnicalParameter; this.txtSeries.Text = resource.Series; this.txtModelNumber.Text = resource.ModelNumber; this.txtNote.Text = resource.Note; if (resource.SupplierId.HasValue) { XPM_Basic_ContactCorp corp = (from c in entities.XPM_Basic_ContactCorp where c.CorpID == resource.SupplierId select c).FirstOrDefault <XPM_Basic_ContactCorp>(); if (corp != null) { this.txtSupplier.Text = corp.CorpName; this.hfldSupplier.Value = corp.CorpID.ToString(); } } if (resource.Res_Attribute != null) { this.ddlAttribute.SelectedValue = resource.Res_Attribute.AttributeId; } if (resource.Res_Unit != null) { this.ddlUnit.SelectedValue = resource.Res_Unit.UnitId; } goto Label_05D9; } } this.lblTitle.Text = "新增资源"; this.hdGuid.Value = Guid.NewGuid().ToString(); this.txtResourceCode.Text = this.GenerateResCode(); Label_05D9: this.BindGv(); }
public static int?GetSupplierIdByName(string SupplierName) { int?nullable = null; using (pm2Entities entities = new pm2Entities()) { XPM_Basic_ContactCorp corp = (from m in entities.XPM_Basic_ContactCorp where m.CorpName == SupplierName select m).FirstOrDefault <XPM_Basic_ContactCorp>(); if (corp != null) { nullable = new int?(corp.CorpID); } } return(nullable); }