protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = e.RowIndex; HiddenField supIdHidden = (HiddenField)GridView1.Rows[id].FindControl("SupplierID"); SSISEntities entityContext = new SSISEntities(); Guid guid = Guid.NewGuid(); Random random = new Random(); int key = random.Next(); String Item_Number = DropDownList2.SelectedValue.Trim(); String ItemID = entityContext.Stationery_Catalogue.Where(x => x.Description == Item_Number).Select(z => z.Item_Number).First(); // Remove from grid and supplier-item tables Supplier_Item si = entityContext.Supplier_Item.Where(x => x.Supplier_ID == supIdHidden.Value && x.Item_Number == ItemID).First(); entityContext.Supplier_Item.Remove(si); entityContext.SaveChanges(); loadData(); // Response.Redirect("MaintainSupplierInformation.aspx"); }
protected void btn_add_new_suppl_Click(object sender, EventArgs e) { String Name = tbx_name.Text; String iD = tbx_id.Text; String Address = tbx_address.Text; int num = Convert.ToInt32(tbx_contactno.Text); String Cname = tbx_cntctname.Text; int fno = Convert.ToInt32(tbx_fax.Text); String GST = tbx_gst.Text; String Remark = tbx_remark.Text; try { using (SSISEntities entity = new SSISEntities()) { Supplier sup = new Supplier { Supplier_ID = iD, Supplier_Name = Name, Address = Address, Contact_Number = num, Contact_Name = Cname, Fax_Number = fno, GST_Number = GST, Remarks = Remark }; entity.Suppliers.Add(sup); entity.SaveChanges(); foreach (ListItem item in ListBox1.Items) { if (item.Selected) { string ItemNumber = item.Value; Supplier_Item si = new Supplier_Item { Supplier_ID = iD, Item_Number = ItemNumber }; entity.Supplier_Item.Add(si); entity.SaveChanges(); } } } } catch { lblexcep.Text = "Supplier ID already Exist.Please try with different Id."; lblexcep.BackColor = System.Drawing.Color.Red; lblexcep.ForeColor = System.Drawing.Color.White; lblexcep.Visible = true; } Response.Redirect("~/com.ssis.PurchaseDepartmentRepresentative/MaintainSupplierInformation.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { supplierID = ViewState["suppID"].ToString(); int id = Int32.Parse(supplierID); Supplier_Item s = model.Supplier_Item.Where(x => x.Supplier_Item_ID == id).First(); Supplier supplier = model.Suppliers.Where(x => x.Supplier_ID == s.Supplier_ID).First(); list.Add(supplier.Supplier_Name); Session["ShoppingCartSupplierCart"] = list; Response.Redirect("Store_MakePurchaseOrder.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { string Description = DropDownList1.SelectedItem.ToString(); string Rank = RadioButtonList1.SelectedValue; string ItemNo; //try //{ using (SSISEntities entity = new SSISEntities()) { string stationeryCata = entity.Stationery_Catalogue.Where(p => p.Description == Description).Select(p => p.Item_Number).First().ToString(); Supplier_Item supplier_Item = entity.Supplier_Item.Where(y => y.Item_Number == stationeryCata).First(); ItemNo = entity.Stationery_Catalogue.Where(k => k.Description == Description).Select(k => k.Item_Number).First().ToString(); supplier_Item.Supplier_ID = suppliername.ToString(); supplier_Item.Rank = Rank.ToString(); supplier_Item.Price = Double.Parse(TextBox1.Text); entity.SaveChanges(); Save(); } using (SSISEntities entity = new SSISEntities()) { if (Rank.ToString() == "1") { Stationery_Catalogue sc = entity.Stationery_Catalogue.Where(s => s.Item_Number == ItemNo).First(); sc.Price = Double.Parse(TextBox1.Text); entity.SaveChanges(); Save(); } } //} //catch (Exception exp) //{ // Response.Write(exp.ToString()); //} Response.Redirect("~/com.ssis.PurchaseDepartmentRepresentative/MaintainSupplierInformation.aspx"); }