private void btn_save_Click(object sender, EventArgs e) { if (txt_title.Text.Trim() == "") { CustomControls.Alert.show("title", "Enter Title", 1500); } try { var i = new tax() { taxcate_id = (comboBox1.SelectedItem as Model.taxcategory).id, title = txt_title.Text, created_at = DateTime.Now, updated_at = DateTime.Now }; db.taxes.Add(i); db.SaveChanges(); add?.Invoke(i); this.Close(); } catch (Exception ex) { CustomControls.Alert.show("Erroe", "Error Data", 1500); } }
public void loaddata(int id) { tax i = db.taxes.Where(o => o.id == id).First(); comboBox1.Text = (i.taxcategory as Model.taxcategory).name; txt_title.Text = i.title; this.id = id; }
public ActionResult Update(int id, FormCollection form) { try { tax target = new tax(); //get property TryUpdateModel(target, new string[] { "tax_anme", "tax_value", "city", "state", "county", "zipcode", "start_date", "end_date", "deleted", "in_city" }, form.ToValueProvider()); target.tax_anme = "State Tax"; target.city = ""; target.county = ""; target.zipcode = ""; target.deleted = false; target.in_city = false; target.end_date = new DateTime(2222, 1, 1); ViewBag.Error = null; // Update Previous Tax Detail string query = ""; int PrevId = 0; DateTime dt1 = target.start_date; dt1 = dt1.AddDays(-1); var ctx1 = new ckdatabase(); query = "Select Top 1 tax_number from taxes where tax_anme = 'State Tax' and state = '" + target.state + "' and start_date<'" + target.start_date + "' and deleted=0 order by start_date Desc"; PrevId = ctx1.Database.SqlQuery <int>(query).FirstOrDefault <int>(); if (PrevId != 0) { query = "Update taxes set end_date='" + dt1 + "' where tax_anme='State Tax' and state='" + target.state + "'"; query = query + " and tax_number='" + PrevId.ToString() + "'"; var ctx2 = new ckdatabase(); int noOfRowUpdated = ctx2.Database.ExecuteSqlCommand(query); } db.taxes.Add(target); db.SaveChanges(); ViewBag.m = "The State Tax was successfully created " + "on " + System.DateTime.Now; //return View(target); string search = null; return(RedirectToAction("ListTax", new { search, msg = ViewBag.m })); } catch (Exception e) { ViewBag.m = "The State Tax was not created " + e.Message; return(View()); } }
public ActionResult Edit(int id, FormCollection fo) { try { List <tax> tax_list = db.taxes.Where(d => d.tax_number == id).ToList(); ViewBag.Employeeslist = tax_list; tax target = tax_list[0]; TryUpdateModel(target, new string[] { "tax_anme", "tax_value", "city", "state", "county", "zipcode", "start_date", "end_date", "deleted", "in_city" }, fo.ToValueProvider()); target.tax_anme = "State Tax"; target.city = ""; target.county = ""; target.zipcode = ""; target.deleted = false; target.in_city = false; ViewBag.Error = null; // Update Previous Tax Detail string query = ""; int PrevId = 0; DateTime dt1 = (DateTime)target.start_date; DateTime dt2 = new DateTime(2222, 1, 1);; dt1 = dt1.AddDays(-1); var ctx1 = new ckdatabase(); query = "Select Top 1 tax_number from taxes where tax_anme = 'State Tax' and state = '" + target.state + "' and start_date<'" + target.start_date + "' and deleted=0 and tax_number<> '" + id.ToString() + "' order by start_date Desc"; PrevId = ctx1.Database.SqlQuery <int>(query).FirstOrDefault <int>(); if (PrevId != 0) { query = "Update taxes set end_date='" + dt1 + "' where tax_anme='State Tax' and state='" + target.state + "'"; query = query + " and tax_number='" + PrevId.ToString() + "'"; var ctx2 = new ckdatabase(); int noOfRowUpdated = ctx2.Database.ExecuteSqlCommand(query); } db.SaveChanges(); ViewBag.m = " The state tax was successfully updated " + " on " + System.DateTime.Now; //return View(target); string search = null; return(RedirectToAction("ListTax", new { search, msg = ViewBag.m })); } catch (Exception e) { ViewBag.m = "Something went wrong ... " + e.Message; return(View()); } }
//string Emp = null, /* * public ActionResult StateTax() * { * * try * { * * var state = new List<SelectListItem> * { * // new SelectListItem() { Text = "WV", Selected = true, Value = "" } * }; * state.AddRange(db.taxes.Where(CCVV => CCVV.state != null).Select(b => new SelectListItem * * { * Text = b.state, * Selected = true, * Value = b.state.ToString() * }).Distinct()); * ViewBag.state = state; * * var result = db.taxes.Where(l => ((l.state=="Type") && l.tax_anme == "State Tax")).ToList(); * //LogController.lst = result; * return View(); * * //return View(db.leads.Where(x => (x.project_name.Contains(search) || search == null) && x.project_status_number == type && (x.project_status_number != 6 && x.deleted == false)).ToList()); * } * catch (Exception e) * { * ViewBag.m = "Something went wrong ... " + e.Message; * return View(); * } * } * * */ /* public ActionResult StateTax(int? page, string search = null, string Type = null, string Start = null, string end = null, string msg = null) * { * * * DateTime start = string.IsNullOrEmpty(Start) ? DateTime.MinValue : DateTime.Parse(Start); * DateTime end2 = string.IsNullOrEmpty(end) ? DateTime.MaxValue : DateTime.Parse(end); * TimeSpan ts = new TimeSpan(23, 59, 59); * end2 = end2.Date + ts; * * * try * { * ViewBag.m = msg; * var ClassInfo = new List<SelectListItem>(); * * ClassInfo.AddRange(db.taxes.Where(CCVV => CCVV.state != null).Select(b => new SelectListItem * * { * Text = b.state, * Selected = true, * Value = b.state.ToString() * }).Distinct()); * ViewBag.lead_type = ClassInfo; * * * * * var result = db.taxes.Where(l => (l.state == Type) && l.tax_anme == "State Tax" ).ToList(); * //LogController.lst = result; * * // return View(result.ToPagedList(page ?? 1, 8)); * * return View(db.leads.Where(x => (x.project_name.Contains(search) || search == null) && x.project_status_number == type && (x.project_status_number != 6 && x.deleted == false)).ToList()); * } * catch (Exception e) * { * ViewBag.m = "Something went wrong ... " + e.Message; * return View(); * } * } * * * * */ /* * public ActionResult StateTax(FormCollection form) * { * try * { * //setting dropdown list for forgern key * var state = new List<SelectListItem>(); * state.AddRange(db.taxes.Where(x => x.state != null).Select(a => new SelectListItem * { * Text = a.state, * Selected = false, * Value = a.state.ToString() * }).Distinct()); * * //setting variable passing * ViewBag.state = state; * * //create instance * tax target = new tax(); * //get property * TryUpdateModel(target, new string[] { "tax_value", "tax_anme", "city", "state", "county", "zipcode", "end_date", "tax_number", "start_date" }, form.ToValueProvider()); * * //validate * // double tempPhoneNumber = 0; * ViewBag.Error = null; * * * { * target.tax_anme = "State Tax"; * target.city = ""; * target.county = ""; * target.zipcode = ""; * * target.start_date = System.DateTime.Now; * target.end_date = System.DateTime.Now; * * db.taxes.Add(target); * db.SaveChanges(); * ViewBag.m = "Tax was successfully updated " + "on " + System.DateTime.Now; * } * return View(); * * * * * } * * * catch (Exception e) * { * ViewBag.m = "The customer was not created ... " + e.Message; * return View(); * } * } * */ public ActionResult StateTax(FormCollection form) { try { //setting dropdown list for forgern key var state = new List <SelectListItem>(); state.AddRange(db.taxes.Where(x => x.state != null).Select(a => new SelectListItem { Text = a.state, Selected = false, Value = a.state.ToString() }).Distinct()); //setting variable passing ViewBag.state = state; //create instance tax target = new tax(); //get property TryUpdateModel(target, new string[] { "tax_value", "tax_anme", "city", "state", "county", "zipcode", "end_date", "tax_number", "start_date" }, form.ToValueProvider()); //validate // double tempPhoneNumber = 0; ViewBag.Error = null; { target.tax_anme = "State Tax"; target.city = ""; target.county = ""; target.zipcode = ""; target.start_date = System.DateTime.Now; target.end_date = System.DateTime.Now; db.taxes.Add(target); db.SaveChanges(); ViewBag.m = "Tax was successfully updated " + "on " + System.DateTime.Now; } return(View()); } catch (Exception e) { ViewBag.m = "The Tax was not created ... " + e.Message; return(View()); } }
public ActionResult AddTax(FormCollection form) { tax target = new tax(); //get property TryUpdateModel(target, new string[] { "tax_anme", "tax_value", "city", "state", "county", "zipcode", "start_date", "end_date" }, form.ToValueProvider()); //validate if (string.IsNullOrEmpty(target.tax_anme)) { ModelState.AddModelError("tax_anme", "Tax Type is required"); } if (ModelState.IsValid) { db.taxes.Add(target); db.SaveChanges(); } return(View(target)); }
public ActionResult Delete(int id) { try { List <tax> CountyTax_list = db.taxes.Where(d => d.tax_number == id).ToList(); ViewBag.Customerslist = CountyTax_list; tax target = CountyTax_list[0]; target.deleted = true; db.SaveChanges(); ViewBag.m = "The count Tax was successfully deleted."; string search = null; return(RedirectToAction("CountyTaxNew", new { search, msg = ViewBag.m })); } catch (Exception e) { ViewBag.m = "The County Tax was not deleted ..." + e.Message; string search = null; return(RedirectToAction("CountyTaxNew", new { search, msg = ViewBag.m })); } }
public ActionResult Update(int id) { try { //setting dropdown list for forgern key var utype = new List <SelectListItem>(); utype.AddRange(db.users_types.Where(x => x.deleted != true).Select(a => new SelectListItem { Text = a.user_type_name, Selected = false, Value = a.user_type_number.ToString() })); var branchtypes = new List <SelectListItem>(); branchtypes.AddRange(db.branches.Where(x => x.deleted != true).Select(b => new SelectListItem { Text = b.branch_name, Selected = false, Value = b.branch_number.ToString() })); //setting variable passing ViewBag.utype = utype; ViewBag.branch = branchtypes; ViewBag.id = id; List <tax> tax_list = db.taxes.Where(d => d.tax_number == id).ToList(); ViewBag.Customerslist = tax_list; tax target = tax_list[0]; //branchtypes.Where(q => int.Parse(q.Value) == target.branch.branch_number).First().Selected = true; //utype.Where(t => int.Parse(t.Value) == target.users_types.user_type_number).First().Selected = true; return(View(target)); } catch (Exception e) { ViewBag.m = "Something went wrong ... " + e.Message; return(View()); } }
private void Newitem_savedata(tax tax) { add(tax); }