Пример #1
0
        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");
            }
        }
Пример #2
0
        public void UpdateDealer(object parameter)
        {
            int     delar_id = 0;
            TextBox tb       = (TextBox)parameter;

            int.TryParse(tb.Text, out delar_id);
            if (delar_id > 0)
            {
                dealer        ob_dealer = Delars.Where(s => s.id == delar_id).First();
                List <dealer> temp_list = DelarServices.GetDelarByName(ob_dealer.dealer_name.Trim());
                if (temp_list.Count == 0 || temp_list.Count == 1)
                {
                    if (temp_list.Count == 1)
                    {
                        dealer temp = temp_list.FirstOrDefault();
                        if (temp.id != ob_dealer.id)
                        {
                            BindGrid();
                            RaisedPropertyChanged("Delars");
                            return;
                        }
                    }
                    int temp_delar_id = DelarServices.AddUpdateDealer(ob_dealer);
                    if (temp_delar_id == ob_dealer.id)
                    {
                        //MessageBox.Show("Dealer " + ob_dealer.dealer_name + " is Updated");
                        InventoryHelper.SuccessAlert("Success", "Dealer " + ob_dealer.dealer_name + " is Updated");
                        BindGrid();
                        RaisedPropertyChanged("Delars");
                    }
                }
                else
                {
                    // MessageBox.Show("Dealer Name already Exist");
                    InventoryHelper.SimpleAlert("Warning", "Dealer Name already Exist");
                }
            }
        }