protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); int iindex = (int)editedItem.GetDataKeyValue("ItemID"); //Prepare new row to add it in the DataSource DataRow[] changedRows = this.UpdateGetItems(iindex).Select("ItemID= " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ItemID"]); if (changedRows.Length != 1) { RadGrid1.Controls.Add(new LiteralControl("Unable to locate the Item for updating.")); e.Canceled = true; return; } //Update new values Hashtable newValues = new Hashtable(); newValues["Formula"] = (userControl.FindControl("ddlTOC") as DropDownList).SelectedItem.Value; int ellValue = Int32.Parse(UpdateGetItems(iindex).Rows[0]["ItemID"].ToString()); string Uformula = newValues["Formula"].ToString(); changedRows[0].BeginEdit(); try { foreach (DictionaryEntry entry in newValues) { changedRows[0][(string)entry.Key] = entry.Value; } changedRows[0].EndEdit(); this.UpdateGetItems(iindex).AcceptChanges(); using (adage_45Entities a = new adage_45Entities()) { var grid = (from g in a.xxItemForms where g.ItemID == ellValue select g).SingleOrDefault(); grid.Formula = Uformula; a.SaveChanges(); } } catch (Exception ex) { changedRows[0].CancelEdit(); Label lblError = new Label(); lblError.Text = "Unable to update Employees. Reason: " + ex.Message; lblError.ForeColor = System.Drawing.Color.Red; RadGrid1.Controls.Add(lblError); e.Canceled = true; } }
public void Load_Grid() { using (adage_45Entities a = new adage_45Entities()) { var grid = (from g in a.xxItemHeaders select new { g.ProductDesription, g.Lnumber, g.Company }).ToList(); RadGrid1.DataSource = grid; RadGrid1.DataBind(); } }
public List <ItemFormula> IFORM(int IID) { using (adage_45Entities a = new adage_45Entities()) { var grid = (from g in a.xxItemForms where g.ItemID == IID select new ItemFormula { ItemID = g.ItemID, Formula = g.Formula, HeaderID = g.HeaderID, PostTreated = g.PostTreated }).ToList(); return(grid); } }
public void Load_Grid() { string LiD = Request.QueryString["id"]; txtLnumber.Text = LiD.ToString(); using (adage_45Entities a = new adage_45Entities()) { var grid = (from g in a.xxItemForms where g.Lnumber == LiD select new { g.HeaderID, g.Formula, g.ItemID }).ToList(); RadGrid1.DataSource = grid; } }
public List <ItemFormula> AFORM() { string LiD = Request.QueryString["id"]; txtLnumber.Text = LiD.ToString(); using (adage_45Entities a = new adage_45Entities()) { var grid = (from g in a.xxItemForms where g.Lnumber == LiD select new ItemFormula { ItemID = g.ItemID, Formula = g.Formula, HeaderID = g.HeaderID, PostTreated = g.PostTreated }).ToList(); return(grid); } }
protected void Page_Load(object sender, EventArgs e) { string LiD = Request.QueryString["id"]; txtLnumber.Text = LiD.ToString(); using (adage_45Entities i = new adage_45Entities()) { var SItem = (from g in i.xxItemHeaders where g.Lnumber == LiD select g).FirstOrDefault(); if (SItem.Company == "SMC") { lblCountryAnswer.Text = "Yes"; } else { lblCountryAnswer.Text = "No"; } } }
public void Control_Load() { using (adage_45Entities a = new adage_45Entities()) { cbMicron.DataSource = a.pmap_Micron.ToList(); cbMicron.DataValueField = "pmap_Micron1"; cbMicron.DataTextField = "pmap_Micron1"; cbMicron.DataBind(); cbGeometry.DataSource = a.pmap_Geometry.ToList(); cbGeometry.DataValueField = "pmap_Geometry1"; cbGeometry.DataTextField = "pmap_Geometry1"; cbGeometry.DataBind(); cbPhysicalForm.DataSource = a.pmap_PhysicalForm.ToList(); cbPhysicalForm.DataValueField = "pmap_PhysicalForm1"; cbPhysicalForm.DataTextField = "pmap_PhysicalForm1"; cbPhysicalForm.DataBind(); cbSolvent.DataSource = a.pmap_Solvent.ToList(); cbSolvent.DataValueField = "pmap_Solvent1"; cbSolvent.DataTextField = "pmap_Solvent1"; cbSolvent.DataBind(); cbCharacteristics.DataSource = a.pmap_Characteristic.ToList(); cbCharacteristics.DataValueField = "pmap_Characteristic1"; cbCharacteristics.DataTextField = "pmap_Characteristic1"; cbCharacteristics.DataBind(); cbSurfaceTreatment.DataSource = a.pmap_SurfaceTreatment.ToList(); cbSurfaceTreatment.DataValueField = "pmap_SurfaceTreatment1"; cbSurfaceTreatment.DataTextField = "pmap_SurfaceTreatment1"; cbSurfaceTreatment.DataBind(); cbSystem.DataSource = a.pmap_System.ToList(); cbSystem.DataValueField = "pmap_System1"; cbSystem.DataTextField = "pmap_System1"; cbSystem.DataBind(); cbTypeApplication.DataSource = a.pmap_Type_Application.ToList(); cbTypeApplication.DataValueField = "pmap_Type_Application1"; cbTypeApplication.DataTextField = "pmap_Type_Application1"; cbTypeApplication.DataBind(); #region Product Class Designation var Market = (from m in a.item_class_ext where m.Type == "Market Segment" select m.Description).ToList(); cbMarketSegment.DataSource = Market; cbMarketSegment.DataBind(); var TNF = (from m in a.item_class_ext where m.Type == "Trade Name First" select m.Description).ToList(); cbTradeNameFirst.DataSource = TNF; cbTradeNameFirst.DataBind(); var TNS = (from m in a.item_class_ext where m.Type == "Trade Name Second" select m.Description).ToList(); cbTradeNameSecond.DataSource = TNS; cbTradeNameSecond.DataBind(); var Carrier = (from m in a.item_class_ext where m.Type == "Carrier" select m.Description).ToList(); cbCarrier.DataSource = Carrier; cbCarrier.DataBind(); var PCC = (from m in a.item_class_ext where m.Type == "Product Class Charateristics" select m.Description).ToList(); cbClassCharacteristics.DataSource = PCC; cbClassCharacteristics.DataBind(); var PCLPS = (from m in a.item_class_ext where m.Type == "Product Class Leaf & Particle Size" select m.Description).ToList(); cbLeafParticle.DataSource = PCLPS; cbLeafParticle.DataBind(); #endregion Load_Grid(); } }
public void Submit_Header(object sender, EventArgs e) { if (Page.IsValid) { var ps = new StringBuilder(); var collection = cbPackage.CheckedItems; using (adage_45Entities context = new adage_45Entities()) { xxItemHeader item = new xxItemHeader(); { item.CreatedDate = DateTime.UtcNow; item.CreatedBy = "System"; item.Market = txtMarket.Text; item.ProductDesription = txtProductDescription.Text; item.NewOrExisting = cbNorE.Text; item.ShelfLife = txtShelfLife.Text; item.ProductStatus = cbProductStatus.Text; item.Lnumber = txtLnumber.Text; item.Company = cbCompany.Text; item.Waterborne = cbWaterBorne.Text; item.Characteristics = cbCharacteristics.Text; item.Geometry = cbGeometry.Text; item.Micron = cbMicron.Text; item.PhysicalForm = cbPhysicalForm.Text; item.Solvent = cbSolvent.Text; item.SurfaceTreatment = cbSurfaceTreatment.Text; item.System = cbSystem.Text; item.TypeApplication = cbTypeApplication.Text; item.SMCTruckPricePerLB = txtTruckPrice.Text; foreach (var package in collection) { ps.Append(package.Text + ";"); } item.Packages = ps.ToString(); item.StaticDissipativeLiner = cbLiner.Text; item.WhereWillProductBeUsed = CbWhereUsed.Text; item.Status = "Open"; item.MarketSegment = cbMarketSegment.Text; item.TradeNameFirst = cbTradeNameFirst.Text; item.TradeNameSecond = cbTradeNameSecond.Text; item.ProductClassLeaf = cbLeafParticle.Text; item.ProductClassCharacteristic = cbClassCharacteristics.Text; item.Carrier = cbCarrier.Text; item.RequestedDate = dpReqDate.SelectedDate; } context.xxItemHeaders.Add(item); context.SaveChanges(); } Reset_Controls(); Response.Redirect(Request.Url.ToString(), false); } }
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) { string LiD = Request.QueryString["id"]; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); //Create new row in the DataSource DataRow newRow = this.NewGetItems().NewRow(); //Insert new values Hashtable newValues = new Hashtable(); newValues["Formula"] = (userControl.FindControl("ddlTOC") as DropDownList).SelectedItem.Value; newValues["PostTreated"] = (userControl.FindControl("ddPostTreated") as DropDownList).SelectedItem.Value; try { //make sure that unique primary key value is generated for the inserted row if (NewGetItems().Rows.Count == 0) { newValues["ItemID"] = 1; } else { newValues["ItemID"] = (int)this.NewGetItems().Rows[this.NewGetItems().Rows.Count - 1]["ItemID"] + 1; } foreach (DictionaryEntry entry in newValues) { newRow[(string)entry.Key] = entry.Value; } this.NewGetItems().Rows.Add(newRow); this.NewGetItems().AcceptChanges(); string formula = newValues["Formula"].ToString(); string posttreated = newValues["PostTreated"].ToString(); using (adage_45Entities a = new adage_45Entities()) { var headerinfo = (from g in a.xxItemHeaders where g.Lnumber == LiD select g).FirstOrDefault(); var grid = (from g in a.xxItemForms select g).FirstOrDefault(); grid.HeaderID = headerinfo.ItemID; grid.Lnumber = LiD; grid.Formula = formula; grid.PostTreated = posttreated; a.xxItemForms.Add(grid); a.SaveChanges(); RadGrid1.Rebind(); } } catch (Exception ex) { Label lblError = new Label(); lblError.Text = "Unable to insert Employees. Reason: " + ex.Message; lblError.ForeColor = System.Drawing.Color.Red; RadGrid1.Controls.Add(lblError); e.Canceled = true; } }