protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownListinvoicetype.DataSource = DB.Invoice_Ts.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Invoice_T_Id, name = a.Invoice_T_Name }); DropDownListinvoicetype.DataBind(); if (DropDownListinvoicetype.SelectedValue == "1") { DropDownListcontac.DataSource = DB.Contact2s.Where(a => a.IsDisable.Equals(false) && a.Client_Type.Equals(1)).Select(a => new { ID = a.Contact_Id, name = a.Contact_Name }); DropDownListcontac.DataBind(); DropDownListcontacttype2.SelectedValue = "1"; } else if (DropDownListinvoicetype.SelectedValue == "2") { DropDownListcontac.DataSource = DB.Contact2s.Where(a => a.IsDisable.Equals(false) && a.Client_Type.Equals(3)).Select(a => new { ID = a.Contact_Id, name = a.Contact_Name }); DropDownListcontac.DataBind(); DropDownListcontacttype2.SelectedValue = "3"; } DropDownListItem.DataSource = DB.Items.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Items_Id, Name = a.Items_Name }); DropDownListItem.DataBind(); DropDownListItem.Items.Insert(0, new ListItem("Choose", "0")); DropDownListcontac.Items.Insert(0, new ListItem("Choose", "0")); DropDownListcontacttype2.DataSource = DB.Contat_Ts.Where(a => a.IsDisable.Equals(false)).Select(a => new { a.Contat_T_Id, a.Contat_T_Name }); DropDownListcontacttype2.DataBind(); } }
protected void btnSumbititem_Click(object sender, EventArgs e) { Item newobject = new Item(); newobject.RecTime = DateTime.Now; newobject.User_Id = 0; newobject.IsDisable = false; newobject.AverageCost = Convert.ToDouble(TextBoxcost0.Text); newobject.HasStock = Convert.ToInt32(CheckBoxhasstock.Checked); newobject.Items_Name = TextBoxName.Text; newobject.Items_Notes = "ADD by invoice page"; newobject.Items_Price = Convert.ToDouble(textboxprice.Text); newobject.Type_Id = Convert.ToInt32(DropDownListitem0.SelectedValue); DB.Items.InsertOnSubmit(newobject); DB.SubmitChanges(); if (CheckBoxhasstock.Checked == true) { Stock newstock = new Stock(); newstock.Item_Id = newobject.Items_Id; newstock.IsDisable = false; if (TextBoxquantity.Text != "") { newstock.Stock_Quantity = Convert.ToInt32(TextBoxquantity.Text); } else { newstock.Stock_Quantity = 0; } newstock.LastModifyDate = DateTime.Now; newstock.Last_UserId = 0; DB.Stocks.InsertOnSubmit(newstock); DB.SubmitChanges(); } DropDownListItem.DataSource = DB.Items.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Items_Id, Name = a.Items_Name }).OrderByDescending(a => a.ID); DropDownListItem.DataBind(); changedrop(); }
protected void dropdownlist() { DropDownListItem.DataSource = DB.Items.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Items_Id, Name = a.Items_Name }); DropDownListItem.DataBind(); }
protected void databind(string id) { Invoice object1 = DB.Invoices.Where(a => a.Invoice_Id.Equals(id)).SingleOrDefault(); //GridView1.DataSource = DB.Bank_Names.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.BankName_Id, Name = a.Bank_Name1, a.AccountNo, DateOFOpen = a.DateOfOpen, a.Phone, a.Loation, a.PersonInCharge, a.Phone_PersonInCharge, Note = a.Bank_Name_Notes }); ; //GridView1.DataBind(); DropDownListinvoicetype.DataSource = DB.Invoice_Ts.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Invoice_T_Id, name = a.Invoice_T_Name }); DropDownListinvoicetype.DataBind(); DropDownListinvoicetype.SelectedValue = Convert.ToString(object1.Invoice_Type_Id); DropDownListcontacttype2.DataSource = DB.Contat_Ts.Where(a => a.IsDisable.Equals(false)).Select(a => new { a.Contat_T_Id, a.Contat_T_Name }); DropDownListcontacttype2.DataBind(); if (DropDownListinvoicetype.SelectedValue == "1") { DropDownListcontac.DataSource = DB.Contact2s.Where(a => a.IsDisable.Equals(false) && a.Client_Type.Equals(3)).Select(a => new { ID = a.Contact_Id, name = a.Contact_Name }); DropDownListcontac.DataBind(); DropDownListcontacttype2.SelectedValue = "3"; } else if (DropDownListinvoicetype.SelectedValue == "2") { DropDownListcontac.DataSource = DB.Contact2s.Where(a => a.IsDisable.Equals(false) && a.Client_Type.Equals(1)).Select(a => new { ID = a.Contact_Id, name = a.Contact_Name }); DropDownListcontac.DataBind(); DropDownListcontacttype2.SelectedValue = "1"; } TextBoxInvoiceno.Text = Convert.ToString(Convert.ToInt32(DB.Invoice_Serial_Collects.Where(a => a.Invoice_Serial_Collect_Collecting.Equals(DropDownListinvoicetype.SelectedValue)).SingleOrDefault().Invoice) + 1); datepicker.Text = Convert.ToString(DateTime.Now); DropDownListItem.DataSource = DB.Items.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Items_Id, Name = a.Items_Name }); DropDownListItem.DataBind(); DropDownListtax.DataSource = DB.Taxes.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Tax_Id, name = a.Tax_Name }); DropDownListtax.DataBind(); Labelid.Text = Convert.ToString(id); TextBoxAfterDiscount.Text = Convert.ToString(object1.Invoice_AfterDiscountprice); TextBoxTax.Text = Convert.ToString(object1.Invoice_AfterDiscountprice_ATax); datepicker.Text = Convert.ToString(object1.Invoice_Date); //CheckBoxDone.Checked = Convert.ToBoolean(object1.Invoice_IsDone); TextBoxInvoiceno.Text = Convert.ToString(object1.Invoice_No); TextBoxNote.Text = object1.Invoice_Note; TextBoxtotalprice.Text = Convert.ToString(object1.Invoice_Price); TextBoxcost.Text = Convert.ToString(object1.Invoice_TotalCost); //DropDownListinvoicetype.SelectedValue = Convert.ToString(object1.Invoice_Type_Id); DropDownListcontac.SelectedValue = Convert.ToString(object1.Contact_Id); Labelstatus.Text = "Invoice No=" + object1.Invoice_No + " -Date of Invoice" + object1.Invoice_Date; TextBoxtaxpercentage0.Text = Convert.ToString(DB.Taxes.Where(a => a.Tax_Id.Equals(DropDownListtax.SelectedValue)).SingleOrDefault().Tax_Percentage); DropDownListitem0.DataSource = DB.Item_Types.Where(a => a.IsDisable.Equals(false)).Select(a => new { ID = a.Item_Type1, name = a.Item_Type_Name }); DropDownListitem0.DataBind(); }