protected void btnSumbitcontact_Click(object sender, EventArgs e) { Contact2 newobject = new Contact2(); newobject.Client_Type = Convert.ToInt32(DropDownListcontacttype2.SelectedValue); newobject.Contact_Location = TextBoxlocation.Text; newobject.Contact_Mobile = TextBoxmobile.Text; newobject.Contact_Name = TextBoxContactName.Text; newobject.Contact_Note = "Add From invoice page"; newobject.Contact_Phone = "00000"; newobject.Contact_Rectime = DateTime.Now; newobject.IsDisable = false; newobject.Rectime = DateTime.Now; newobject.UserID = Convert.ToInt32(Session["userid"]); DB.Contact2s.InsertOnSubmit(newobject); DB.SubmitChanges(); 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 }).OrderByDescending(a => a.ID); DropDownListcontac.DataBind(); } 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 }).OrderByDescending(a => a.ID);; DropDownListcontac.DataBind(); } }
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 DropDownListinvoicetype_SelectedIndexChanged(object sender, EventArgs e) { 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(); DropDownListcontac.Items.Insert(0, new ListItem("Choose", "0")); } 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(); DropDownListcontac.Items.Insert(0, new ListItem("Choose", "0")); } }
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(); }