示例#1
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtIdProduct.Text == "")
                {
                    Product product = new Product();
                    product.Name         = txtProduct.Text;
                    product.CreationDate = System.DateTime.Now;

                    ProductBS productBs = new ProductBS();
                    product.Id        = productBs.AddProduct(product);
                    txtIdProduct.Text = product.Id.ToString();

                    MessageBox.Show("Produto " + product.Name + " ID " + product.Id + "Salvo com sucesso");
                }
                else
                {
                    Product product = new Product();
                    product.Id           = int.Parse(txtIdProduct.Text);
                    product.Name         = txtProduct.Text;
                    product.CreationDate = System.DateTime.Now;

                    ProductBS productBs = new ProductBS();
                    product.Id = productBs.EditProduct(product);

                    MessageBox.Show("Produto " + product.Name + " ID " + product.Id + "Alterado com sucesso");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("ERRO: " + ex.Message);
            }
        }
示例#2
0
        public AddProductClient(AddClient parent)
        {
            InitializeComponent();

            ProductBS productBs = new ProductBS();

            productList            = productBs.getAllProduct();
            cboProduct.ItemsSource = productList;
            this.parent            = parent;
        }
示例#3
0
        private void BtnFilter_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ProductBS          productBs = new ProductBS();
                ProductFilterModel model     = new ProductFilterModel();
                model.Name = txtProductName.Text;
                model.CreationDateBegin = dtBegin.SelectedDate;
                model.CreationDateEnd   = dtEnd.SelectedDate;

                productList = productBs.getProductByFilter(model);
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERRO: " + ex.Message);
            }
            grdProduct.ItemsSource = productList;
        }
 public Products()
 {
     productBS = new ProductBS();
 }