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 BtnRemove_Click(object sender, EventArgs e)
 {
     if ((dgvSubmit.RowCount - 1) == 0)
     {
         MessageBox.Show("List import is empty");
     }
     else
     {
         flag = dgvSubmit.CurrentCell.RowIndex;
         if (flag != -1)
         {
             string id                   = listImport.ElementAt(flag).ProductID;
             float  lastPrice            = listImport.ElementAt(flag).lastPrice;
             string date                 = listImport.ElementAt(flag).DateImport;
             int    currentNumberPackage = ProDAO.getNumberPackageByID(id);
             int    currentNumSub        = ProDAO.getNumSub(id);
             int    numberImport         = listImport.ElementAt(flag).NumberPackageImport;
             int    numSubImport         = listImport.ElementAt(flag).numSub;
             listImport.RemoveAt(flag);
             bool check      = importDAO.removeImportByDateTime(date);
             bool checkReset = ProDAO.updateProduct(currentNumberPackage - numberImport, currentNumSub - numSubImport, lastPrice, id);
             if (check && checkReset)
             {
                 MessageBox.Show("Remove successful");
                 loadData(listImport);
                 flag = -1;
             }
             else
             {
                 MessageBox.Show("Remove fail");
                 flag = -1;
             }
         }
         else
         {
             MessageBox.Show("Please choose product to Remove");
         }
     }
 }