private void btn_activeordeactive_Click(object sender, RoutedEventArgs e) { try { object item = dataGrid_Coustomer.SelectedItem; if (item == null) { MessageBox.Show("لطفا مشتری را انتخاب کنید", "راهنمایی", MessageBoxButton.OK, MessageBoxImage.Information); return; } int CoustomerID = Convert.ToInt32((dataGrid_Coustomer.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text); Coustomer c = (from cu in database.Coustomers where cu.CoutomerID == CoustomerID select cu).SingleOrDefault(); if (c.CoustomerActive == 1) { c.CoustomerActive = 2; } else { c.CoustomerActive = 1; } database.SaveChanges(); MyMessageBox.ShowMessageSuccess("اطلاعات مشتری به روز شد"); ShowCustomerINfo(SearchStatement); } catch { MessageBox.Show("مشکلی در غیر فعال کردن مشتری به وجود آمده است"); } }
// DELETE api/values/5 public IHttpActionResult DeleteById(int id) { Coustomer c = new Coustomer(); c.Del(id); return(Ok()); }
// POST api/values public IHttpActionResult insert(Coustomer us) { Coustomer u = new Coustomer(); u.insert(us); return(Ok()); }
public IHttpActionResult GetCoustomer(int id) { Coustomer sc = new Coustomer(); Coustomer cc = sc.show(id); return(Ok(cc)); }
public IHttpActionResult get(string name) { Coustomer sc = new Coustomer(); IList <Coustomer> cc = sc.Search(name); return(Ok(cc)); }
public IHttpActionResult GetCoust(string option) { Coustomer sc = new Coustomer(); IList <Coustomer> cc = cc = sc.GetRecordss(option); return(Ok(cc)); }
public IHttpActionResult GetCoustomer() { Coustomer sc = new Coustomer(); IList <Coustomer> cc = cc = sc.GetRecord(); return(Ok(cc)); }
private void button_Copy1_Click(object sender, RoutedEventArgs e) { if (!cheknullabalbel()) { return; } try { switch (Window_State) { case 1: { Coustomer c = new Coustomer(); c.CoustomerName = txt_CustomerName.Text; c.CoustomerTell = txttellcustomer.Text.Trim(); c.CoustoemrAddres = txt_Xoustomer.Text.Trim(); c.UserID = PublicVariable.GUserID; c.SetDate = lbl_date.Content.ToString(); c.CoustomerActive = 1; database.Coustomers.Add(c); database.SaveChanges(); MyMessageBox.ShowMessageSuccess(); break; } case 2: { Coustomer cu = (from C in database.Coustomers where C.CoutomerID == this.CID select C).SingleOrDefault(); cu.CoustomerName = txt_CustomerName.Text.Trim(); cu.CoustomerTell = txttellcustomer.Text.Trim(); cu.CoustoemrAddres = txt_Xoustomer.Text.Trim(); cu.UpdateDate = lbl_date.Content.ToString(); database.SaveChanges(); MyMessageBox.ShowMessageSuccess("اطلاعات مشتری ها به روز شد"); break; } } } catch { MessageBox.Show("در ارتباط با دیتا بیس مشکلی به وجود آمده است لطفا دئباره تلاش کنید"); } finally { this.Close(); } }
public ActionResult Create(Coustomer us) { HttpClient bh = new HttpClient(); bh.BaseAddress = new Uri("http://localhost:63007/api/values/"); var insertdata = bh.PostAsJsonAsync("insert", us); var sa = insertdata.Result; if (sa.IsSuccessStatusCode) { return(RedirectToAction("index")); } return(View("Create")); }
public ActionResult Delete(int id) { Coustomer us = null; HttpClient bh = new HttpClient(); bh.BaseAddress = new Uri("http://localhost:63007/api/values/"); var c = bh.GetAsync("GetCoustomer?id=" + id); c.Wait(); var reader = c.Result; if (reader.IsSuccessStatusCode) { var disdata = reader.Content.ReadAsAsync <Coustomer>(); disdata.Wait(); us = disdata.Result; } return(View(us)); }
public ActionResult Delete(Coustomer U) { Coustomer us = null; int id = Int32.Parse(U.RoomNO); HttpClient bh = new HttpClient(); bh.BaseAddress = new Uri("http://localhost:63007/api/values/"); var c = bh.DeleteAsync("DeleteById?id=" + id.ToString()); c.Wait(); var reader = c.Result; if (reader.IsSuccessStatusCode) { return(RedirectToAction("index")); } return(View()); }