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("مشکلی در غیر فعال کردن مشتری به وجود آمده است");
     }
 }
예제 #2
0
        // DELETE api/values/5
        public IHttpActionResult DeleteById(int id)
        {
            Coustomer c = new Coustomer();

            c.Del(id);
            return(Ok());
        }
예제 #3
0
        // POST api/values
        public IHttpActionResult insert(Coustomer us)
        {
            Coustomer u = new Coustomer();

            u.insert(us);
            return(Ok());
        }
예제 #4
0
        public IHttpActionResult GetCoustomer(int id)
        {
            Coustomer sc = new Coustomer();
            Coustomer cc = sc.show(id);

            return(Ok(cc));
        }
예제 #5
0
        public IHttpActionResult get(string name)
        {
            Coustomer         sc = new Coustomer();
            IList <Coustomer> cc = sc.Search(name);

            return(Ok(cc));
        }
예제 #6
0
        public IHttpActionResult GetCoust(string option)
        {
            Coustomer         sc = new Coustomer();
            IList <Coustomer> cc = cc = sc.GetRecordss(option);

            return(Ok(cc));
        }
예제 #7
0
        public IHttpActionResult GetCoustomer()
        {
            Coustomer         sc = new Coustomer();
            IList <Coustomer> cc = cc = sc.GetRecord();

            return(Ok(cc));
        }
예제 #8
0
        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();
            }
        }
예제 #9
0
        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"));
        }
예제 #10
0
        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));
        }
예제 #11
0
        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());
        }