//protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) //{ // GridViewRow row = GridView1.Rows[e.RowIndex]; // string supplierId = (row.FindControl("DropDownList1") as DropDownList).SelectedValue; // //string supplierId = (row.FindControl("Label9") as Label).Text; // //string supplierName = dropDowns[0].SelectedValue. // string supplierName = (row.FindControl("DropDownList1") as DropDownList).SelectedItem.Text; // //Label9.Text = supplierId; // //Label1.Text = supplierName; // //string supplierName= (row.FindControl("TextBox1") as TextBox).Text; // string itemCode = (row.FindControl("Label8") as Label).Text; // string itemDescription = (row.FindControl("TextBox3") as TextBox).Text; // int tenderId = Convert.ToInt32((row.FindControl("Label10") as Label).Text); // decimal price = Convert.ToDecimal((row.FindControl("TextBox5") as TextBox).Text); // int tenderYearId = Convert.ToInt32((row.FindControl("Label11") as Label).Text); // DateTime tenderDate = Convert.ToDateTime((row.FindControl("Label6") as Label).Text); // //string[] dropDownNames = { "DropDownList1" }; // //List<DropDownList> dropDowns = new List<DropDownList>(); // //dropDownNames.ToList().ForEach(name => // //{ // // dropDowns.Add((DropDownList)row.FindControl(name)); // //}); // //string supplierName = dropDowns[0].SelectedValue; // //using (SSISEntities s = new SSISEntities()) // //{ // // Supplier supplierToEdit = s.Suppliers.Find(supplierId); // // supplierToEdit. // //} // var tender = entities.Tender_List_Details.SingleOrDefault(x => x.tender_id == tenderId); // // find tender_year_id for the latest one, with the supplier_id // var tenderYearItem = entities.Tender_List.Where(x => x.supplier_id == supplierId).OrderByDescending(o => o.tender_date); // if (tenderYearItem.Count() > 0) // { // tender.tender_year_id = tenderYearItem.First().tender_year_id; // } // tender.price = price; // //var result1 = entities.Suppliers.SingleOrDefault(x => x.supplier_id == supplierId); // //result1.supplier_id = supplierId; // //entities.SaveChanges(); // var result2 = entities.Stock_Inventory.SingleOrDefault(x => x.item_code == itemCode); // result2.item_description = itemDescription; // entities.SaveChanges(); // //var result3 = entities.Tender_List_Details.SingleOrDefault(x => x.tender_id == tenderId); // //result3.price = price; // //entities.SaveChanges(); // var result4 = entities.Tender_List.SingleOrDefault(x => x.tender_year_id == tenderYearId); // result4.tender_date = tenderDate; // entities.SaveChanges(); // FacadeFactory.GetTenderListService().RedoRankingsForTenderList(); // GridView1.EditIndex = -1; // this.BindGrid(); //} protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; // supplierId = (row.FindControl("DropDownList1") as DropDownList).SelectedValue; //string supplierId = (row.FindControl("Label9") as Label).Text; //string supplierName = dropDowns[0].SelectedValue. // string supplierName = (row.FindControl("DropDownList1") as DropDownList).SelectedItem.Text; //Label9.Text = supplierId; //Label1.Text = supplierName; //string supplierName= (row.FindControl("TextBox1") as TextBox).Text; string itemCode = (row.FindControl("Label8") as Label).Text; //string supplierId = (row.FindControl("Labe9") as Label).Text; //string supplierName = (row.FindControl("Labe20") as Label).Text; string itemDescription = (row.FindControl("TextBox3") as TextBox).Text; int tenderId = Convert.ToInt32((row.FindControl("Label10") as Label).Text); decimal price = Convert.ToDecimal((row.FindControl("TextBox5") as TextBox).Text); int tenderYearId = Convert.ToInt32((row.FindControl("Label11") as Label).Text); DateTime tenderDate = Convert.ToDateTime((row.FindControl("Label6") as Label).Text); //string[] dropDownNames = { "DropDownList1" }; //List<DropDownList> dropDowns = new List<DropDownList>(); //dropDownNames.ToList().ForEach(name => //{ // dropDowns.Add((DropDownList)row.FindControl(name)); //}); //string supplierName = dropDowns[0].SelectedValue; //using (SSISEntities s = new SSISEntities()) //{ // Supplier supplierToEdit = s.Suppliers.Find(supplierId); // supplierToEdit. //} var tender = entities.Tender_List_Details.SingleOrDefault(x => x.tender_id == tenderId); //// find tender_year_id for the latest one, with the supplier_id //var tenderYearItem = entities.Tender_List.Where(x => x.supplier_id == supplierId).OrderByDescending(o => o.tender_date); //if (tenderYearItem.Count() > 0) //{ // tender.tender_year_id = tenderYearItem.First().tender_year_id; //} tender.price = price; //var result1 = entities.Suppliers.SingleOrDefault(x => x.supplier_id == supplierId); //result1.supplier_id = supplierId; //entities.SaveChanges(); var result2 = entities.Stock_Inventory.SingleOrDefault(x => x.item_code == itemCode); result2.item_description = itemDescription; entities.SaveChanges(); //var result3 = entities.Tender_List_Details.SingleOrDefault(x => x.tender_id == tenderId); //result3.price = price; //entities.SaveChanges(); //var result4 = entities.Tender_List.SingleOrDefault(x => x.tender_year_id == tenderYearId); //result4.tender_date = tenderDate; //entities.SaveChanges(); FacadeFactory.GetTenderListService().RedoRankingsForTenderList(); GridView1.EditIndex = -1; this.BindGrid(); }