Пример #1
0
        public static int AddUpdateDealer(dealer ob)
        {
            int delarid = 0;
            using (InventoryEntities db = new InventoryEntities())
            {
                if (ob.id > 0)
                {
                    dealer temp = db.dealers.Where(u => u.id == ob.id).FirstOrDefault();
                    if (temp != null)
                    {
                        temp.id = ob.id;
                        temp.dealer_name = ob.dealer_name;
                        temp.dealer_address = ob.dealer_address;
                    }

                }
                else
                {
                    db.dealers.Add(ob);
                }
                int x = db.SaveChanges();
                if (x > 0)
                {
                    delarid = ob.id;
                }

            }
            return delarid;
        }
        public void AddDealer(object Parameter)
        {
            dealer ob = new dealer();
            ob.id = 0;
            ob.dealer_address = DealerAddress;
            ob.dealer_name = DealerName;
            List<dealer> temp = DelarServices.GetDelarByName(ob.dealer_name.Trim());
            if (temp.Count == 0)
            {
                int temp_dealerid = DelarServices.AddUpdateDealer(ob);
                if (temp_dealerid > 0)
                {
                   // MessageBox.Show("Dealer added successfully");
                    InventoryHelper.SuccessAlert("Success", "Dealer added successfully");
                    DealerAddress = "";
                    DealerName = "";
                }
            }
            else
            {
                InventoryHelper.SimpleAlert("Warning", "Dealer Name already Exist");                   
                //MessageBox.Show("Dealer Name already Exist");
            }

        }
        public static int AddUpdateDealer(dealer ob)
        {
            int delarid = 0;

            using (InventoryEntities db = new InventoryEntities())
            {
                if (ob.id > 0)
                {
                    dealer temp = db.dealers.Where(u => u.id == ob.id).FirstOrDefault();
                    if (temp != null)
                    {
                        temp.id             = ob.id;
                        temp.dealer_name    = ob.dealer_name;
                        temp.dealer_address = ob.dealer_address;
                    }
                }
                else
                {
                    db.dealers.Add(ob);
                }
                int x = db.SaveChanges();
                if (x > 0)
                {
                    delarid = ob.id;
                }
            }
            return(delarid);
        }
        public static bool DeleteDealer(int Dealer_id)
        {
            bool flag = false;

            using (InventoryEntities db = new InventoryEntities())
            {
                dealer temp = db.dealers.Where(u => u.id == Dealer_id).FirstOrDefault();
                if (temp != null)
                {
                    db.dealers.Remove(temp);
                    db.SaveChanges();
                    flag = true;
                }
            }
            return(flag);
        }
Пример #5
0
 public static int AddUpdateDealer(dealer ob)
 {
     return DelarProvider.AddUpdateDealer(ob);
 }