private void BtnUpdate_Click(object sender, EventArgs e)
 {
     if (index == -1)
     {
         MessageBox.Show("please choose a product by click to it to update", "Warning");
     }
     else
     {
         if (string.IsNullOrEmpty(txtProductName.Text))
         {
             MessageBox.Show("please input name of product", "Warning");
         }
         else if (string.IsNullOrEmpty(txtPricePack.Text))
         {
             MessageBox.Show("please input price export a package to udpate", "Warning");
         }
         else if (!ProDAO.checkFloat(txtPricePack.Text) || float.Parse(txtPricePack.Text) <= 0)
         {
             MessageBox.Show("Price must be a possible number and greater than 0", "Warning");
         }
         else if (string.IsNullOrEmpty(txtPriceSub.Text))
         {
             MessageBox.Show("please input price export a package to udpate", "Warning");
         }
         else if (!ProDAO.checkFloat(txtPriceSub.Text) || float.Parse(txtPriceSub.Text) < 0)
         {
             MessageBox.Show("Price must be a possible number and greater than 0", "Warning");
         }
         else
         {
             bool check = ProDAO.updatePriceExportByID(listPro.ElementAt(index).ProductID, float.Parse(txtPricePack.Text), float.Parse(txtPriceSub.Text), txtProductName.Text, txtDescription.Text);
             if (check)
             {
                 MessageBox.Show("Update successfull", "Notification");
                 listPro = ProDAO.getListProduct();
                 loadData(listPro);
                 index               = -1;
                 txtPricePack.Text   = "";
                 txtPriceSub.Text    = "";
                 txtProductName.Text = "";
                 txtDescription.Text = "";
             }
             else
             {
                 MessageBox.Show("Update fail", "Notification");
                 index               = -1;
                 txtPricePack.Text   = "";
                 txtPriceSub.Text    = "";
                 txtProductName.Text = "";
                 txtDescription.Text = "";
             }
         }
     }
 }
        private void BtnImport_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtProductID.Text))
            {
                MessageBox.Show("Please choose a product to import!");
            }
            else if (ValidateChildren(ValidationConstraints.Enabled))
            {
                string id            = txtProductID.Text;
                string dateImport    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                int    numberPackage = int.Parse(txtNumberPacakge.Text);
                int    numSub        = int.Parse(txtNumberSub.Text);
                float  price         = float.Parse(txtPrice.Text);
                int    numpackeLast  = ProDAO.getNumberPackageByID(id);
                int    numSubLast    = ProDAO.getNumSub(id);
                //create iumportDTO
                Import ip = new Import();
                ip.ImportID            = userID;
                ip.ProductID           = id;
                ip.DateImport          = dateImport;
                ip.ImportFrom          = importFrom;
                ip.NumberPackageImport = numberPackage;
                ip.PriceImport         = price * numberPackage;
                ip.PriceOneImport      = price;
                ip.ProductName         = txtProductName.Text;
                ip.lastPrice           = lastPrice;
                ip.numSub = int.Parse(txtNumberSub.Text);

                bool checkUpdateProduct    = ProDAO.updateProduct(numberPackage + numpackeLast, numSub + numSubLast, price, id);
                bool checkInsertIntoImport = importDAO.insertImport(ip);
                if (checkUpdateProduct && checkInsertIntoImport)
                {
                    MessageBox.Show("Import successfull");
                    listProduct = ProDAO.getListProduct();
                    listImport.Add(ip);
                    txtProductID.Text     = "";
                    txtProductName.Text   = "";
                    txtDescription.Text   = "";
                    txtPackage.Text       = "";
                    txtNumberPacakge.Text = "";
                    txtSubPackage.Text    = "";
                    txtNumberSub.Text     = "";
                    txtPrice.Text         = "";
                }
                else
                {
                    MessageBox.Show("Import fail");
                }
            }
        }
 private void ManageProduct_Load(object sender, EventArgs e)
 {
     listPro = ProDAO.getListProduct();
     loadData(listPro);
 }
 private void FrmExport_Load(object sender, EventArgs e)
 {
     listProduct = ProDAO.getListProduct();
     loadData(listProduct);
 }