protected void GridView1_RowCancelingEdit1(object sender, GridViewCancelEditEventArgs e) { try { GridView1.EditIndex = -1; FriendsEntities ent = new FriendsEntities(); var ds = (from wh in ent.Customers select new { wh.Customer_Id, wh.Customer_Name, wh.Customer_Phone, wh.Customer_Fax, wh.Customer_Mobile_Phone, wh.Customer_Email, wh.Customer_Website }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button2_Click(object sender, EventArgs e) { try { Warehouse wh = new Warehouse(); wh.WH_Id = int.Parse(TextBox1.Text); wh.WH_Name = TextBox2.Text; wh.WH_Location = TextBox3.Text; wh.WH_Manager = TextBox4.Text; FriendsEntities ent = new FriendsEntities(); ent.Warehouses.AddObject(wh); ent.SaveChanges(); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; TextBox4.Text = string.Empty; mpePopUp.Show(); Label2.Text = "New Warehouse is added"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button5_Click(object sender, EventArgs e) { try { Sup_Per_Item spi = new Sup_Per_Item(); spi.Sup_Per_Id = int.Parse(TextBox2.Text); spi.Sup_Per_Item_Id = int.Parse(DropDownList2.SelectedValue); spi.Sup_Per_Item_Quantity = int.Parse(TextBox3.Text); spi.Sup_Per_Item_Pro_Date = DateTime.Parse(Request["txtDatePicker2"].ToString()); spi.Sup_Per_Item_Validation = int.Parse(TextBox4.Text); spi.Sup_Id = int.Parse(DropDownList3.SelectedValue); FriendsEntities ent = new FriendsEntities(); ent.Sup_Per_Item.AddObject(spi); ent.SaveChanges(); TextBox4.Text = string.Empty; mpePopUp.Show(); Label2.Text = "item is added to permission number : " + spi.Sup_Per_Id; DropDownList1.SelectedValue = default; DropDownList2.SelectedValue = default; DropDownList3.SelectedValue = default; TextBox4.Text = string.Empty; TextBox3.Text = string.Empty; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button3_Click(object sender, EventArgs e)//get all { try { FriendsEntities ent = new FriendsEntities(); var ds = (from wh in ent.Customers select new { wh.Customer_Id, wh.Customer_Name, wh.Customer_Phone, wh.Customer_Fax, wh.Customer_Mobile_Phone, wh.Customer_Email, wh.Customer_Website }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int id = (int)GridView1.DataKeys[e.RowIndex].Value; FriendsEntities ent = new FriendsEntities(); var item = (from itm in ent.Items where itm.Item_Id == id select itm).First(); ent.Items.DeleteObject(item); ent.SaveChanges(); var ds = (from itms in ent.Items select new { itms.Item_Id, itms.Item_Code, itms.Item_Name }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); mpePopUp.Show(); Label2.Text = "The item is Deleted"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button2_Click(object sender, EventArgs e) { try { Customer wh = new Customer(); wh.Customer_Id = int.Parse(TextBox1.Text); wh.Customer_Name = TextBox2.Text; wh.Customer_Phone = int.Parse(TextBox3.Text); wh.Customer_Fax = int.Parse(TextBox4.Text); wh.Customer_Mobile_Phone = int.Parse(TextBox5.Text); wh.Customer_Email = TextBox6.Text; wh.Customer_Website = TextBox7.Text; FriendsEntities ent = new FriendsEntities(); ent.Customers.AddObject(wh); ent.SaveChanges(); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; TextBox4.Text = string.Empty; TextBox5.Text = string.Empty; TextBox6.Text = string.Empty; TextBox7.Text = string.Empty; mpePopUp.Show(); Label2.Text = "New Customer is added"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { string name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_name")).Text; int code = int.Parse(((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_code")).Text); int id = (int)GridView1.DataKeys[e.RowIndex].Value; FriendsEntities ent = new FriendsEntities(); var wh = (from itm in ent.Items where itm.Item_Id == id select itm).First(); wh.Item_Name = name; wh.Item_Code = code; ent.SaveChanges(); GridView1.EditIndex = -1; var ds = (from itms in ent.Items select new { itms.Item_Id, itms.Item_Code, itms.Item_Name }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); mpePopUp.Show(); Label2.Text = " the item is Updated"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int id = (int)GridView1.DataKeys[e.RowIndex].Value; FriendsEntities ent = new FriendsEntities(); var wh = (from warehouse in ent.Customers where warehouse.Customer_Id == id select warehouse).First(); ent.Customers.DeleteObject(wh); ent.SaveChanges(); var ds = (from wh2 in ent.Customers select new { wh2.Customer_Id, wh2.Customer_Name, wh2.Customer_Phone, wh2.Customer_Fax, wh2.Customer_Mobile_Phone, wh2.Customer_Email, wh2.Customer_Website }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); mpePopUp.Show(); Label2.Text = "The Customer is Deleted"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button9_Click(object sender, EventArgs e) { try { FriendsEntities ent = new FriendsEntities(); var res = from e1 in ent.Items join e2 in ent.Ex_Per_Item on e1.Item_Id equals e2.Ex_Per_Item_Id join c in ent.Customers on e2.Cus_ID equals c.Customer_Id join ep in ent.Export_Permission on e2.Ex_Per_Id equals ep.Ex_Per_Id join wh in ent.Warehouses on ep.Ex_Per_WH_Id equals wh.WH_Id select new { Ex_Per_Id = e2.Ex_Per_Id, WH_Name = wh.WH_Name, Ex_Per_Date = ep.Ex_Per_Date, Item_Name = e1.Item_Name, Ex_Per_Item_Quantity = e2.Ex_Per_Item_Quantity, Customer_Name = c.Customer_Name }; GridView1.DataSource = res; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button5_Click(object sender, EventArgs e) { try { Ex_Per_Item epi = new Ex_Per_Item(); epi.Ex_Per_Id = int.Parse(TextBox2.Text); epi.Ex_Per_Item_Id = int.Parse(DropDownList2.SelectedValue); epi.Cus_ID = int.Parse(DropDownList3.SelectedValue); epi.Ex_Per_Item_Quantity = int.Parse(TextBox4.Text); FriendsEntities ent = new FriendsEntities(); ent.Ex_Per_Item.AddObject(epi); ent.SaveChanges(); TextBox4.Text = string.Empty; mpePopUp.Show(); Label2.Text = "item is added to permission number : " + epi.Ex_Per_Id; DropDownList1.SelectedValue = default; DropDownList2.SelectedValue = default; DropDownList3.SelectedValue = default; //ep.Ex_Per_WH_Id = int.Parse(DropDownList1.SelectedValue); //ep.Ex_Per_Date = DateTime.Parse(Request["txtDatePicker3"].ToString()); //FriendsEntities ent = new FriendsEntities(); //ent.Export_Permission.AddObject(ep); //ent.SaveChanges(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button2_Click(object sender, EventArgs e) { try { Transfer t = new Transfer(); t.Trans_Id = int.Parse(TextBox3.Text); t.WH_From_Id = int.Parse(DropDownList1.SelectedValue); t.WH_To_Id = int.Parse(DropDownList2.SelectedValue); t.Item_Id = int.Parse(DropDownList3.SelectedValue); t.Quantity = int.Parse(TextBox1.Text); t.Sup_Id = int.Parse(DropDownList4.SelectedValue); t.Pro_Date = DateTime.Parse(Request["txtDatePicker3"].ToString()); t.Validation = int.Parse(TextBox2.Text); FriendsEntities ent = new FriendsEntities(); ent.Transfers.AddObject(t); ent.SaveChanges(); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; DropDownList1.SelectedValue = default; DropDownList2.SelectedValue = default; DropDownList3.SelectedValue = default; DropDownList4.SelectedValue = default; mpePopUp.Show(); Label2.Text = "New Transfer Done"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int id = (int)GridView1.DataKeys[e.RowIndex].Value; FriendsEntities ent = new FriendsEntities(); var wh = (from warehouse in ent.Warehouses where warehouse.WH_Id == id select warehouse).First(); ent.Warehouses.DeleteObject(wh); ent.SaveChanges(); var ds = (from wh2 in ent.Warehouses select new { wh2.WH_Id, wh2.WH_Name, wh2.WH_Location, wh2.WH_Manager }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); mpePopUp.Show(); Label2.Text = "The Warehouse is Deleted"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button2_Click(object sender, EventArgs e) { try { Item itm = new Item(); itm.Item_Id = int.Parse(TextBox1.Text); itm.Item_Code = int.Parse(TextBox2.Text); itm.Item_Name = TextBox3.Text; FriendsEntities ent = new FriendsEntities(); ent.Items.AddObject(itm); ent.SaveChanges(); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; mpePopUp.Show(); Label2.Text = "New Item is added"; var itms = (from itm2 in ent.Items select new { itm2.Item_Id, itm2.Item_Name }); DropDownList1.DataSource = itms; DropDownList1.DataTextField = "Item_Name"; DropDownList1.DataValueField = "Item_Id"; DropDownList1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { //WH1 FriendsEntities ent = new FriendsEntities(); var WH = (from itm in ent.Warehouses select new { itm.WH_Id, itm.WH_Name }); DropDownList1.DataSource = WH; DropDownList1.DataTextField = "WH_Name"; DropDownList1.DataValueField = "WH_Id"; DropDownList1.DataBind(); //WH2 var WH2 = (from itm in ent.Warehouses select new { itm.WH_Id, itm.WH_Name }); DropDownList2.DataSource = WH; DropDownList2.DataTextField = "WH_Name"; DropDownList2.DataValueField = "WH_Id"; DropDownList2.DataBind(); //Item FriendsEntities ent2 = new FriendsEntities(); var itms = (from itm in ent2.Items select new { itm.Item_Id, itm.Item_Name }); DropDownList3.DataSource = itms; DropDownList3.DataTextField = "Item_Name"; DropDownList3.DataValueField = "Item_Id"; DropDownList3.DataBind(); //Supplier FriendsEntities ent3 = new FriendsEntities(); var sups = (from itm in ent3.Suppliers select new { itm.Supplier_Id, itm.Supplier_Name }); DropDownList4.DataSource = sups; DropDownList4.DataTextField = "Supplier_Name"; DropDownList4.DataValueField = "Supplier_Id"; DropDownList4.DataBind(); } } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { string name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_name")).Text; string phone = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_phone")).Text; string fax = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_fax")).Text; string mobile = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_mobile")).Text; string email = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_email")).Text; string website = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_website")).Text; int id = (int)GridView1.DataKeys[e.RowIndex].Value; FriendsEntities ent = new FriendsEntities(); var wh = (from warehouse in ent.Customers where warehouse.Customer_Id == id select warehouse).First(); wh.Customer_Name = name; wh.Customer_Email = email; wh.Customer_Website = website; wh.Customer_Phone = int.Parse(phone); wh.Customer_Mobile_Phone = int.Parse(mobile); wh.Customer_Fax = int.Parse(fax); ent.SaveChanges(); ent.SaveChanges(); GridView1.EditIndex = -1; var ds = (from wh2 in ent.Customers select new { wh2.Customer_Id, wh2.Customer_Name, wh2.Customer_Phone, wh2.Customer_Fax, wh2.Customer_Mobile_Phone, wh2.Customer_Email, wh2.Customer_Website }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); mpePopUp.Show(); Label2.Text = " the Customer is Updated"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button5_Click(object sender, EventArgs e) { try { Items_MU mu = new Items_MU(); mu.Item_Id = int.Parse(DropDownList1.SelectedValue); mu.MU_Name = TextBox4.Text; FriendsEntities ent = new FriendsEntities(); ent.Items_MU.AddObject(mu); ent.SaveChanges(); TextBox4.Text = string.Empty; DropDownList1.SelectedValue = default; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { //WH FriendsEntities ent = new FriendsEntities(); var WH = (from itm in ent.Warehouses select new { itm.WH_Id, itm.WH_Name }); DropDownList1.DataSource = WH; DropDownList1.DataTextField = "WH_Name"; DropDownList1.DataValueField = "WH_Id"; DropDownList1.DataBind(); //Item FriendsEntities ent2 = new FriendsEntities(); var itms = (from itm in ent2.Items select new { itm.Item_Id, itm.Item_Name }); DropDownList2.DataSource = itms; DropDownList2.DataTextField = "Item_Name"; DropDownList2.DataValueField = "Item_Id"; DropDownList2.DataBind(); //Customer FriendsEntities ent3 = new FriendsEntities(); var custs = (from itm in ent3.Customers select new { itm.Customer_Id, itm.Customer_Name }); DropDownList3.DataSource = custs; DropDownList3.DataTextField = "Customer_Name"; DropDownList3.DataValueField = "Customer_Id"; DropDownList3.DataBind(); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; } } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button2_Click(object sender, EventArgs e) { try { Export_Permission ep = new Export_Permission(); ep.Ex_Per_Id = int.Parse(TextBox1.Text); ep.Ex_Per_WH_Id = int.Parse(DropDownList1.SelectedValue); ep.Ex_Per_Date = DateTime.Parse(Request["txtDatePicker3"].ToString()); FriendsEntities ent = new FriendsEntities(); ent.Export_Permission.AddObject(ep); ent.SaveChanges(); mpePopUp.Show(); Label2.Text = "Permission Done"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button9_Click(object sender, EventArgs e) { try { int duration = 30 * int.Parse(TextBox2.Text); FriendsEntities ent = new FriendsEntities(); DateTime now = DateTime.Now; int month = now.Month - duration; DateTime old = now.AddDays(-duration); var res = from e1 in ent.Items join e2 in ent.Sup_Per_Item on e1.Item_Id equals e2.Sup_Per_Item_Id join c in ent.Suppliers on e2.Sup_Id equals c.Supplier_Id join ep in ent.Supply_Permission on e2.Sup_Per_Id equals ep.Sup_Per_Id join wh in ent.Warehouses on ep.Sup_Per_WH_Id equals wh.WH_Id join e3 in ent.Supply_Permission on e2.Sup_Per_Id equals e3.Sup_Per_Id where (e2.Sup_Per_Item_Pro_Date.Month - e2.Sup_Per_Item_Validation < old.Month) //needs time select new { Sup_Per_Id = e2.Sup_Per_Id, WH_Name = wh.WH_Name, Sup_Per_Date = ep.Sup_Per_Date, Item_Name = e1.Item_Name, Sup_Per_Item_Quantity = e2.Sup_Per_Item_Quantity, Sup_Per_Item_Pro_Date = e2.Sup_Per_Item_Pro_Date, Sup_Per_Item_Validation = e2.Sup_Per_Item_Validation, Supplier_Name = c.Supplier_Name }; GridView7.DataSource = res; GridView7.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { FriendsEntities ent = new FriendsEntities(); var itms = (from itm in ent.Items select new { itm.Item_Id, itm.Item_Name }); DropDownList1.DataSource = itms; DropDownList1.DataTextField = "Item_Name"; DropDownList1.DataValueField = "Item_Id"; DropDownList1.DataBind(); } } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { try { GridView1.EditIndex = e.NewEditIndex; FriendsEntities ent = new FriendsEntities(); var ds = (from itms in ent.Items select new { itms.Item_Id, itms.Item_Code, itms.Item_Name }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button3_Click(object sender, EventArgs e) { try { FriendsEntities ent = new FriendsEntities(); var ds = (from itms in ent.Items select new { itms.Item_Id, itms.Item_Code, itms.Item_Name }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { try { GridView1.EditIndex = -1; FriendsEntities ent = new FriendsEntities(); var ds = (from wh in ent.Warehouses select new { wh.WH_Id, wh.WH_Name, wh.WH_Location, wh.WH_Manager }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { string name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_name")).Text; string location = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_loc")).Text; string manager = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txt_manager")).Text; int id = (int)GridView1.DataKeys[e.RowIndex].Value; FriendsEntities ent = new FriendsEntities(); var wh = (from warehouse in ent.Warehouses where warehouse.WH_Id == id select warehouse).First(); wh.WH_Name = name; wh.WH_Location = location; wh.WH_Manager = manager; ent.SaveChanges(); GridView1.EditIndex = -1; var ds = (from wh2 in ent.Warehouses select new { wh2.WH_Id, wh2.WH_Name, wh2.WH_Location, wh2.WH_Manager }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); mpePopUp.Show(); Label2.Text = " the Warehouse is Updated"; } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button3_Click(object sender, EventArgs e) { try { FriendsEntities ent = new FriendsEntities(); var ds = (from wh in ent.Warehouses select new { wh.WH_Id, wh.WH_Name, wh.WH_Location, wh.WH_Manager }).ToList(); GridView1.DataSource = ds; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button3_Click(object sender, EventArgs e) { try { FriendsEntities ent2 = new FriendsEntities(); var res = from wh1 in ent2.Warehouses join t1 in ent2.Transfers on wh1.WH_Id equals t1.WH_From_Id join wh2 in ent2.Warehouses on t1.WH_To_Id equals wh2.WH_Id join itm in ent2.Items on t1.Item_Id equals itm.Item_Id join s in ent2.Suppliers on t1.Sup_Id equals s.Supplier_Id select new { Trans_Id = t1.Trans_Id, WH_Name = wh1.WH_Name, WH_Name2 = wh2.WH_Name, Item_Name = itm.Item_Name, Quantity = t1.Quantity, Supplier_Name = s.Supplier_Name, Pro_Date = t1.Pro_Date, Validation = t1.Validation }; GridView1.DataSource = res; GridView1.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
public FriendController(FriendsEntities _db) { db = _db; }
protected void Button2_Click(object sender, EventArgs e) { try { int x = int.Parse(DropDownList1.SelectedValue); DateTime dtf = DateTime.Parse(Request["txtDatePicker2"].ToString()); DateTime dtt = DateTime.Parse(Request["txtDatePicker3"].ToString()); //WH suplying report FriendsEntities ent = new FriendsEntities(); var res = from e1 in ent.Items join e2 in ent.Sup_Per_Item on e1.Item_Id equals e2.Sup_Per_Item_Id join c in ent.Suppliers on e2.Sup_Id equals c.Supplier_Id join ep in ent.Supply_Permission on e2.Sup_Per_Id equals ep.Sup_Per_Id join wh in ent.Warehouses on ep.Sup_Per_WH_Id equals wh.WH_Id where wh.WH_Id == x && ep.Sup_Per_Date >= dtf && ep.Sup_Per_Date <= dtt select new { Sup_Per_Id = e2.Sup_Per_Id, WH_Name = wh.WH_Name, Sup_Per_Date = ep.Sup_Per_Date, Item_Name = e1.Item_Name, Sup_Per_Item_Quantity = e2.Sup_Per_Item_Quantity, Sup_Per_Item_Pro_Date = e2.Sup_Per_Item_Pro_Date, Sup_Per_Item_Validation = e2.Sup_Per_Item_Validation, Supplier_Name = c.Supplier_Name }; GridView1.DataSource = res; GridView1.DataBind(); //WH export report FriendsEntities ent2 = new FriendsEntities(); var res2 = from e1 in ent2.Items join e2 in ent2.Ex_Per_Item on e1.Item_Id equals e2.Ex_Per_Item_Id join c in ent2.Customers on e2.Cus_ID equals c.Customer_Id join ep in ent2.Export_Permission on e2.Ex_Per_Id equals ep.Ex_Per_Id join wh in ent2.Warehouses on ep.Ex_Per_WH_Id equals wh.WH_Id where wh.WH_Id == x && ep.Ex_Per_Date >= dtf && ep.Ex_Per_Date <= dtt select new { Ex_Per_Id = e2.Ex_Per_Id, WH_Name = wh.WH_Name, Ex_Per_Date = ep.Ex_Per_Date, Item_Name = e1.Item_Name, Ex_Per_Item_Quantity = e2.Ex_Per_Item_Quantity, Customer_Name = c.Customer_Name }; GridView2.DataSource = res2; GridView2.DataBind(); } catch { mpePopUp.Show(); Label2.Text = "try again"; } }
protected void Button6_Click(object sender, EventArgs e) { try { int item = int.Parse(DropDownList2.SelectedValue); int ware = int.Parse(DropDownList3.SelectedValue); bool itms = CheckBox2.Checked; bool wares = CheckBox3.Checked; DateTime dtf = DateTime.Parse(Request["txtDatePicker6"].ToString()); DateTime dtt = DateTime.Parse(Request["txtDatePicker7"].ToString()); FriendsEntities ent2 = new FriendsEntities(); if (itms && wares) { var res = from wh1 in ent2.Warehouses join t1 in ent2.Transfers on wh1.WH_Id equals t1.WH_From_Id join wh2 in ent2.Warehouses on t1.WH_To_Id equals wh2.WH_Id join itm in ent2.Items on t1.Item_Id equals itm.Item_Id join s in ent2.Suppliers on t1.Sup_Id equals s.Supplier_Id select new { Trans_Id = t1.Trans_Id, WH_Name = wh1.WH_Name, WH_Name2 = wh2.WH_Name, Item_Name = itm.Item_Name, Quantity = t1.Quantity, Supplier_Name = s.Supplier_Name, Pro_Date = t1.Pro_Date, Validation = t1.Validation }; GridView5.DataSource = res; GridView5.DataBind(); } else if (itms && !wares) { var res = from wh1 in ent2.Warehouses join t1 in ent2.Transfers on wh1.WH_Id equals t1.WH_From_Id join wh2 in ent2.Warehouses on t1.WH_To_Id equals wh2.WH_Id join itm in ent2.Items on t1.Item_Id equals itm.Item_Id join s in ent2.Suppliers on t1.Sup_Id equals s.Supplier_Id where t1.WH_From_Id == ware || t1.WH_To_Id == ware select new { Trans_Id = t1.Trans_Id, WH_Name = wh1.WH_Name, WH_Name2 = wh2.WH_Name, Item_Name = itm.Item_Name, Quantity = t1.Quantity, Supplier_Name = s.Supplier_Name, Pro_Date = t1.Pro_Date, Validation = t1.Validation }; GridView5.DataSource = res; GridView5.DataBind(); } else if (!itms && wares) { var res = from wh1 in ent2.Warehouses join t1 in ent2.Transfers on wh1.WH_Id equals t1.WH_From_Id join wh2 in ent2.Warehouses on t1.WH_To_Id equals wh2.WH_Id join itm in ent2.Items on t1.Item_Id equals itm.Item_Id join s in ent2.Suppliers on t1.Sup_Id equals s.Supplier_Id where itm.Item_Id == item select new { Trans_Id = t1.Trans_Id, WH_Name = wh1.WH_Name, WH_Name2 = wh2.WH_Name, Item_Name = itm.Item_Name, Quantity = t1.Quantity, Supplier_Name = s.Supplier_Name, Pro_Date = t1.Pro_Date, Validation = t1.Validation }; GridView5.DataSource = res; GridView5.DataBind(); } else { var res = from wh1 in ent2.Warehouses join t1 in ent2.Transfers on wh1.WH_Id equals t1.WH_From_Id join wh2 in ent2.Warehouses on t1.WH_To_Id equals wh2.WH_Id join itm in ent2.Items on t1.Item_Id equals itm.Item_Id join s in ent2.Suppliers on t1.Sup_Id equals s.Supplier_Id where itm.Item_Id == item && (t1.WH_From_Id == ware || t1.WH_To_Id == ware) select new { Trans_Id = t1.Trans_Id, WH_Name = wh1.WH_Name, WH_Name2 = wh2.WH_Name, Item_Name = itm.Item_Name, Quantity = t1.Quantity, Supplier_Name = s.Supplier_Name, Pro_Date = t1.Pro_Date, Validation = t1.Validation }; GridView5.DataSource = res; GridView5.DataBind(); } } catch { mpePopUp.Show(); Label2.Text = "try again"; } }