예제 #1
0
        private void purchase_btn_Click(object sender, RoutedEventArgs e)
        {
            int  n;
            bool isNumeric = int.TryParse(this.price.Text, out n);
            int  n2;
            bool isNumeric2 = int.TryParse(this.size.Text, out n2);

            if (string.IsNullOrWhiteSpace(this.pid.Text))
            {
                if (string.IsNullOrWhiteSpace(this.pid.Text))
                {
                    pid.Background = Brushes.Red;
                }
                MessageBox.Show("Validate");
                return;
            }
            if ((isNumeric == false) || string.IsNullOrWhiteSpace(this.category.Text) || (isNumeric2 == false) || string.IsNullOrWhiteSpace(this.color.Text) || string.IsNullOrWhiteSpace(this.brand.Text) || string.IsNullOrWhiteSpace(this.purchaseDate.Text))
            {
                search_btn_Click(sender, e);
                if (string.IsNullOrWhiteSpace(this.pid.Text))
                {
                    return;
                }
            }

            saleBO sale = new saleBO();

            sale.Pid          = this.pid.Text;
            sale.PurchaseDate = this.purchaseDate.Text;

            //MessageBox.Show(item.Pid + " " + item.Price + " " + item.Category + " " + item.Size + " " + item.Color + " " + item.Brand + " " + item.Date);

            saleBLL salebl = new saleBLL();
            int     rv     = salebl.ssaleItem(sale);

            if (rv == 0)
            {
                MessageBox.Show("Soled");
                this.pid.Text      = null;
                this.price.Text    = null;
                this.category.Text = null;
                this.size.Text     = null;
                this.color.Text    = null;
                this.brand.Text    = null;

                //this.quantity.Text = null;
            }
            else if (rv == 3)
            {
                MessageBox.Show("Product Is Not Available");
                this.pid.Text = null;
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
예제 #2
0
        public int saleItem(saleBO sale)
        {
            DataClassesDataContext data;
            string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\BCS DATA\Samester 6\C Sharp\Assingment 1\DAL\styloDatabase.mdf;Integrated Security=True";

            using (data = new DataClassesDataContext(constr))
            {
                var check = from a in data.Items
                            where a.PID == sale.Pid
                            select a;
                if (!check.Any())
                {
                    return(3);
                }
                else
                {
                    foreach (var s in check)
                    {
                        s.Quantity = 0;
                    }
                }
                Sale newItem = new Sale
                {
                    PID       = sale.Pid,
                    Sale_Date = sale.PurchaseDate
                };

                data.Sales.InsertOnSubmit(newItem);
                try
                {
                    data.SubmitChanges();
                    return(0);
                }
                catch (Exception e)
                {
                    return(1);
                }
            }
        }
예제 #3
0
 public int ssaleItem(saleBO sale)
 {
     return(saleDal.saleItem(sale));
 }