예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ItemsCheck.CheckTextBoxEmpty(tbMfg))
            {
                MessageBox.Show("Please input the MFG");
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbMpn))
            {
                MessageBox.Show("Please input the MPN");
                return;
            }

            if (!ItemsCheck.CheckIntNumber(tbQty))
            {
                MessageBox.Show("The QTY should be an integer value");
                tbQty.Focus();
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbPrice))
            {
                MessageBox.Show("Please input the Price");
                return;
            }
            else
            {
                if (!ItemsCheck.CheckFloatNumber(tbPrice))
                {
                    MessageBox.Show("The Price should be a float number");
                    tbPrice.Focus();
                    return;
                }
            }



            var publicBomOff = new publicbomoffer
            {
                mfg           = tbMfg.Text.Trim(),
                mpn           = tbMpn.Text.Trim(),
                qty           = int.Parse(tbQty.Text.Trim()),
                price         = float.Parse(tbPrice.Text.Trim()),
                cpn           = tbCpn.Text.Trim(),
                userID        = (short)UserInfo.UserId,
                BomCustVendId = this.custVenId,
                enerDay       = DateTime.Now
            };

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                entity.publicbomoffer.AddObject(publicBomOff);
                entity.SaveChanges();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #2
0
파일: OfferItems.cs 프로젝트: windygu/ERP-1
        public bool CheckItems()
        {
            if (!ItemsCheck.CheckTextBoxEmpty(tbMpn))
            {
                MessageBox.Show("Please input the MPN.");
                return(false);
            }

            if (ItemsCheck.CheckTextBoxEmpty(tbMfg) == false)
            {
                MessageBox.Show("Please input the MFG.");
                return(false);
            }

            if (ItemsCheck.CheckTextBoxEmpty(tbVendorName) == false)
            {
                MessageBox.Show("Please input the Vendor Name.");
                return(false);
            }
            if (ItemsCheck.CheckTextBoxEmpty(tbContact) == false)
            {
                MessageBox.Show("Please input the Contact name.");
                return(false);
            }
            if (ItemsCheck.CheckTextBoxEmpty(tbPhone) == false)
            {
                MessageBox.Show("Please input the Phone number.");
                return(false);
            }
            if (ItemsCheck.CheckTextBoxEmpty(tbQuantity) == false)
            {
                MessageBox.Show("Please input the Quantity.");
                return(false);
            }
            else
            {
                if (false == ItemsCheck.CheckIntNumber(tbQuantity))
                {
                    MessageBox.Show("The Quantity should be an integer value");
                    return(false);
                }
            }

            if (ItemsCheck.CheckTextBoxEmpty(tbPrice) == false)
            {
                MessageBox.Show("Please input the Price.");
                return(false);
            }
            else
            {
                if (false == ItemsCheck.CheckFloatNumber(tbPrice))
                {
                    MessageBox.Show("The Price should be a float value");
                    return(false);
                }
            }
            return(true);
        }
예제 #3
0
        public bool CheckValues()
        {
            if (ItemsCheck.CheckTextBoxEmpty(tbPartNo) == false)
            {
                MessageBox.Show("Please input the Part number.");
                return(false);
            }
            if (ItemsCheck.CheckTextBoxEmpty(tbMfg) == false)
            {
                MessageBox.Show("Please input the MFG.");
                return(false);
            }
            if (ItemsCheck.CheckTextBoxEmpty(tbDc) == false)
            {
                MessageBox.Show("Please input the D/C.");
                return(false);
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbQty))
            {
                MessageBox.Show("Please input the Qty value.");
                tbQty.Focus();
                return(false);
            }


            if (!ItemsCheck.CheckIntNumber(tbQty))
            {
                MessageBox.Show("The Qty should be an integer value.");
                tbQty.Focus();
                return(false);
            }


            if (ItemsCheck.CheckTextBoxEmpty(tbQtyShipped) && !ItemsCheck.CheckIntNumber(tbQtyShipped))
            {
                MessageBox.Show("The Qty Shipped should be an integer value.");
                tbQtyShipped.Focus();
                return(false);
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbUnitPrice))
            {
                MessageBox.Show("Please input the Unit Price.");
                tbUnitPrice.Focus();
                return(false);
            }


            if (!ItemsCheck.CheckFloatNumber(tbUnitPrice))
            {
                MessageBox.Show("The Unit Price should be a float value.");
                tbUnitPrice.Focus();
                return(false);
            }

            return(true);
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ItemsCheck.CheckTextBoxEmpty(tbCustomer))
            {
                MessageBox.Show("Please input the Customer Name");
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbMfg))
            {
                MessageBox.Show("Please input the MFG");
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbMpn))
            {
                MessageBox.Show("Please input the MPN");
                return;
            }

            if (!ItemsCheck.CheckIntNumber(tbQty))
            {
                MessageBox.Show("The QTY should be an integer value");
                tbQty.Focus();
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbPrice))
            {
                MessageBox.Show("Please input the Price");
                return;
            }
            else
            {
                if (!ItemsCheck.CheckFloatNumber(tbPrice))
                {
                    MessageBox.Show("The Price should be a float number");
                    tbPrice.Focus();
                    return;
                }
            }

            string sql = string.Format("insert into matchBom(customer,mfg,mpn,qty,price,cpn,buyer,bomOwner,bomdate) values('{0}','{1}','{2}',{3},{4},'{5}','{6}',{7},'{8}')", tbCustomer.Text.Trim(),
                                       tbMfg.Text.Trim(), tbMpn.Text.Trim(), tbQty.Text.Trim(), tbPrice.Text.Trim(), tbCpn.Text.Trim(), tbBuyer.Text.Trim(), UserInfo.UserId, DateTime.Now.ToString());

            db.ExecDataBySql(sql);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #5
0
 private void tbQtyShipped_TextChanged(object sender, EventArgs e)
 {
     if ((!string.IsNullOrWhiteSpace(tbUnitPrice.Text.Trim())) && ItemsCheck.CheckFloatNumber(tbUnitPrice))
     {
         if (ItemsCheck.CheckIntNumber(tbQtyShipped))
         {
             tbTotal.Text = (Convert.ToInt32(tbQtyShipped.Text.Trim()) * Convert.ToSingle(tbUnitPrice.Text.Trim())).ToString();
         }
         else
         {
             tbTotal.Text = "";
         }
     }
 }
예제 #6
0
파일: RfqItems.cs 프로젝트: windygu/ERP-1
        public bool CheckItems()
        {
            if (tbCustomer.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the customer name.");
                tbCustomer.Focus();
                return(false);
            }
            if (tbContact.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the contact name.");
                tbContact.Focus();
                return(false);
            }
            if (tbPhone.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the phone number.");
                tbPhone.Focus();
                return(false);
            }
            if (tbPartNo.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the part number.");
                tbPartNo.Focus();
                return(false);
            }
            if (tbMfg.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the MFG.");
                tbMfg.Focus();
                return(false);
            }
            if (tbDc.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the D/C.");
                tbDc.Focus();
                return(false);
            }
            if (tbQuantity.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please input the quantity.");
                tbDc.Focus();
                return(false);
            }
            else
            {
                if (false == ItemsCheck.CheckIntNumber(tbQuantity))
                {
                    MessageBox.Show("The Quanity should be an integer number.");
                    tbQuantity.Focus();
                    return(false);
                }
            }

            if (tbTargetPrice.Text.Trim().Length != 0 && false == ItemsCheck.CheckFloatNumber(tbTargetPrice))
            {
                MessageBox.Show("The Target Price should be a float number.");
                tbTargetPrice.Focus();
                return(false);
            }

            if (tbResale.Text.Trim().Length != 0 && false == ItemsCheck.CheckFloatNumber(tbResale))
            {
                MessageBox.Show("The Resale should be a float number.");
                tbResale.Focus();
                return(false);
            }

            return(true);
        }
예제 #7
0
        private void btOK_Click(object sender, EventArgs e)
        {
            if (!ItemsCheck.CheckTextBoxEmpty(tbMpn))
            {
                MessageBox.Show("Please input the MPN");
                return;
            }

            if (ItemsCheck.CheckTextBoxEmpty(tbQty) && !ItemsCheck.CheckIntNumber(tbQty))
            {
                MessageBox.Show("The QTY should be an integer value");
                tbQty.Focus();
                return;
            }

            if (ItemsCheck.CheckTextBoxEmpty(tbResale) && !ItemsCheck.CheckFloatNumber(tbResale))
            {
                MessageBox.Show("The Resale should be a float number");
                tbResale.Focus();
                return;
            }
            if (ItemsCheck.CheckTextBoxEmpty(tbCost) && !ItemsCheck.CheckFloatNumber(tbCost))
            {
                MessageBox.Show("The Cost should be a float number");
                tbCost.Focus();
                return;
            }
            string sql;

            if (isNewStockItem)
            {
                sql = string.Format("insert into ambleStock(mpn,mfg,dc,qty,resale,cost,packing,contact,statu,notes,stockDate) values ('{0}','{1}','{2}',{3},{4},{5},'{6}','{7}','{8}','{9}','{10}')",
                                    tbMpn.Text.Trim(), tbMfg.Text.Trim(), tbDc.Text.Trim(),
                                    string.IsNullOrWhiteSpace(tbQty.Text.Trim()) ? "null" : tbQty.Text.Trim(),
                                    string.IsNullOrWhiteSpace(tbResale.Text.Trim()) ? "null" : tbResale.Text.Trim(),
                                    string.IsNullOrWhiteSpace(tbCost.Text.Trim()) ? "null" : tbCost.Text.Trim(),
                                    tbPacking.Text.Trim(),
                                    tbContact.Text.Trim(),
                                    cbStatus.Text.Trim(),
                                    tbNotes.Text.Trim(),
                                    tbDate.Text.Trim()
                                    );
            }
            else
            {
                sql = string.Format("update amblestock set mpn='{0}',mfg='{1}',dc='{2}',qty={3},resale={4},cost={5},packing='{6}',contact='{7}',statu='{8}',notes='{9}',stockDate='{10}' where stockId={11}",
                                    tbMpn.Text.Trim(), tbMfg.Text.Trim(), tbDc.Text.Trim(),
                                    string.IsNullOrWhiteSpace(tbQty.Text.Trim()) ? "null" : tbQty.Text.Trim(),
                                    string.IsNullOrWhiteSpace(tbResale.Text.Trim()) ? "null" : tbResale.Text.Trim(),
                                    string.IsNullOrWhiteSpace(tbCost.Text.Trim()) ? "null" : tbCost.Text.Trim(),
                                    tbPacking.Text.Trim(),
                                    tbContact.Text.Trim(),
                                    cbStatus.Text.Trim(),
                                    tbNotes.Text.Trim(),
                                    tbDate.Text.Trim(),
                                    this.stockId
                                    );
            }

            db.ExecDataBySql(sql);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #8
0
        private void tsbImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Excel文件(*.xls)|*.xls";
            ofd.RestoreDirectory = true;
            ofd.Multiselect      = false;

            if (DialogResult.OK == ofd.ShowDialog())
            {
                DataTable dt = ExcelHelper.ExcelHelper.Import(ofd.FileName);
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                bool hasCustomer = false, hasMpn = false, hasMfg = false, hasQty = false, hasPrice = false, hasCpn = false, hasBuyer = false;
                int  customerColumn = -1, mpnColumn = -1, mfgColumn = -1, qtyColumn = -1, priceColumn = -1, cpnColumn = -1, buyerColumn = -1;
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName.Trim().ToUpper() == "CUSTOMER")
                    {
                        hasCustomer    = true;
                        customerColumn = dt.Columns.IndexOf(dc);
                    }

                    if (dc.ColumnName.Trim().ToUpper() == "MPN")
                    {
                        hasMpn    = true;
                        mpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "MFG")
                    {
                        hasMfg    = true;
                        mfgColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "QTY")
                    {
                        hasQty    = true;
                        qtyColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "PRICE")
                    {
                        hasPrice    = true;
                        priceColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "CPN")
                    {
                        hasCpn    = true;
                        cpnColumn = dt.Columns.IndexOf(dc);
                    }

                    if (dc.ColumnName.Trim().ToUpper() == "BUYER")
                    {
                        hasBuyer    = true;
                        buyerColumn = dt.Columns.IndexOf(dc);
                    }
                }
                if (false == (hasCustomer && hasMpn && hasMfg && hasQty && hasPrice && hasCpn && hasBuyer))
                {
                    MessageBox.Show("Please check the xls File Column.(CUSTOMER,MFG,MPN,QTY,PRICE,CPN,BUYER)");
                    return;
                }

                int i = 1;

                StringBuilder sb = new StringBuilder();
                sb.Append("insert into matchBom(customer,mfg,mpn,qty,price,cpn,buyer,bomOwner,bomdate) values ");

                foreach (DataRow dr in dt.Rows)
                {
                    //Qty omit the ","
                    string qtyString = dr[qtyColumn].ToString();
                    qtyString = qtyString.Replace(",", string.Empty);

                    if (!string.IsNullOrWhiteSpace(qtyString) && (!ItemsCheck.CheckIntNumber(qtyString)))
                    {
                        MessageBox.Show("The Qty value is not correct in row " + i.ToString());
                        return;
                    }
                    if (!string.IsNullOrWhiteSpace(dr[priceColumn].ToString()) && (!ItemsCheck.CheckFloatNumber(dr[priceColumn])))
                    {
                        MessageBox.Show("The Price value is not correct in row " + i.ToString());
                        return;
                    }

                    int?  qtyLocal;
                    float?priceLocal;

                    if (string.IsNullOrWhiteSpace(qtyString))
                    {
                        qtyLocal = null;
                    }
                    else
                    {
                        qtyLocal = Convert.ToInt32(qtyString);
                    }

                    if (string.IsNullOrWhiteSpace(dr[priceColumn].ToString()))
                    {
                        priceLocal = null;
                    }
                    else
                    {
                        priceLocal = Convert.ToSingle(dr[priceColumn]);
                    }

                    sb.AppendFormat("('{0}','{1}','{2}',{3},{4},'{5}','{6}',{7},'{8}'),", dr[customerColumn].ToString(), dr[mfgColumn].ToString(), dr[mpnColumn].ToString(),
                                    qtyLocal.HasValue? qtyLocal.Value.ToString():"null", priceLocal.HasValue? priceLocal.Value.ToString():"null", dr[cpnColumn].ToString(), dr[buyerColumn].ToString(),
                                    UserInfo.UserId, DateTime.Now.ToString());
                }
                string sql = sb.ToString();
                sql = sql.Substring(0, sql.Length - 1);
                db.ExecDataBySql(sql);
            }
            Stock_Load(this, null);
        }
예제 #9
0
        public bool CheckValues()
        {
            if (ItemsCheck.CheckTextBoxEmpty(tbPartNo) == false)
            {
                MessageBox.Show("Please input the Part Number.");
                return(false);
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbMfg))
            {
                MessageBox.Show("Please input the MFG.");
                return(false);
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbDc))
            {
                MessageBox.Show("Please input the D/C.");
                return(false);
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbQty))
            {
                MessageBox.Show("Please input the Qty.");
                return(false);
            }
            else
            {
                if (!ItemsCheck.CheckIntNumber(tbQty))
                {
                    MessageBox.Show("The Qty should be an integer value.");
                    tbQty.Focus();
                    return(false);
                }
            }

            if (ItemsCheck.CheckIntNumber(tbQtyRevd) && (!ItemsCheck.CheckIntNumber(tbQtyRevd)))
            {
                MessageBox.Show("The Qty Recv should be an integer value.");
                tbQtyRevd.Focus();
                return(false);
            }
            if (ItemsCheck.CheckIntNumber(tbQtyCorrected) && (!ItemsCheck.CheckIntNumber(tbQtyCorrected)))
            {
                MessageBox.Show("The Qty Corrected should be an integer value.");
                tbQtyCorrected.Focus();
                return(false);
            }
            if (ItemsCheck.CheckIntNumber(tbQtyAccept) && (!ItemsCheck.CheckIntNumber(tbQtyAccept)))
            {
                MessageBox.Show("The Qty Accept should be an integer value.");
                tbQtyAccept.Focus();
                return(false);
            }
            if (ItemsCheck.CheckIntNumber(tbQtyRejected) && (!ItemsCheck.CheckIntNumber(tbQtyRejected)))
            {
                MessageBox.Show("The Qty Rejected should be an integer value.");
                tbQtyRejected.Focus();
                return(false);
            }
            if (ItemsCheck.CheckIntNumber(tbQtyRtv) && (!ItemsCheck.CheckIntNumber(tbQtyRtv)))
            {
                MessageBox.Show("The Qty RTV should be an integer value.");
                tbQtyRtv.Focus();
                return(false);
            }
            if (ItemsCheck.CheckIntNumber(tbQcPending) && (!ItemsCheck.CheckIntNumber(tbQcPending)))
            {
                MessageBox.Show("The QC/Pending should be an integer value.");
                tbQcPending.Focus();
                return(false);
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbUnitPrice))
            {
                MessageBox.Show("Please input the Unit Price.");
                tbUnitPrice.Focus();
                return(false);
            }

            if (!ItemsCheck.CheckFloatNumber(tbUnitPrice))
            {
                MessageBox.Show("The Unit Price should be a float value.");
                tbUnitPrice.Focus();
                return(false);
            }

            return(true);
        }
예제 #10
0
        private void tsbExportFromExcel_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            DataGridViewRow dgvr      = dataGridView1.SelectedRows[0];
            int             custVenId = Convert.ToInt32(dgvr.Cells["Id"].Value);


            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Excel文件(*.xls)|*.xls";
            ofd.RestoreDirectory = true;
            ofd.Multiselect      = false;

            if (DialogResult.OK == ofd.ShowDialog())
            {
                DataTable dt = ExcelHelper.ExcelHelper.Import(ofd.FileName);
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                bool hasCpn = false, hasMpn = false, hasMfg = false, hasQty = false, hasPrice = false;
                int  cpnColumn = -1, mpnColumn = -1, mfgColumn = -1, qtyColumn = -1, priceColumn = -1;
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName.Trim().ToUpper() == "MPN")
                    {
                        hasMpn    = true;
                        mpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "CPN")
                    {
                        hasCpn    = true;
                        cpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "MFG")
                    {
                        hasMfg    = true;
                        mfgColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "QTY")
                    {
                        hasQty    = true;
                        qtyColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "PRICE")
                    {
                        hasPrice    = true;
                        priceColumn = dt.Columns.IndexOf(dc);
                    }
                }
                if (false == (hasPrice && hasMpn && hasCpn && hasMfg && hasQty))
                {
                    MessageBox.Show("Please check the xls File Column.(CPN,MPN,MFG,QTY,PRICE)");
                    return;
                }

                //  List<publicbomoffer> publicbomOfferList = new List<publicbomoffer>();
                using (BomOfferEntities entity = new BomOfferEntities())
                { int i = 1;
                  foreach (DataRow dr in dt.Rows)
                  {
                      //Qty omit the ","

                      string qtyString = dr[qtyColumn].ToString();
                      qtyString = qtyString.Replace(",", string.Empty);

                      if (!string.IsNullOrWhiteSpace(qtyString) && (!ItemsCheck.CheckIntNumber(qtyString)))
                      {
                          MessageBox.Show("The Qty value is not correct in row " + i.ToString());
                          return;
                      }
                      if (!string.IsNullOrWhiteSpace(dr[priceColumn].ToString()) && (!ItemsCheck.CheckFloatNumber(dr[priceColumn])))
                      {
                          MessageBox.Show("The Price value is not correct in row " + i.ToString());
                          return;
                      }

                      int?  qtyLocal;
                      float?priceLocal;

                      if (string.IsNullOrWhiteSpace(qtyString))
                      {
                          qtyLocal = null;
                      }
                      else
                      {
                          qtyLocal = Convert.ToInt32(qtyString);
                      }

                      if (string.IsNullOrWhiteSpace(dr[priceColumn].ToString()))
                      {
                          priceLocal = null;
                      }
                      else
                      {
                          priceLocal = Convert.ToSingle(dr[priceColumn]);
                      }


                      entity.publicbomoffer.AddObject(
                          new publicbomoffer
                        {
                            mfg           = dr[mfgColumn].ToString(),
                            mpn           = dr[mpnColumn].ToString(),
                            qty           = qtyLocal,
                            price         = priceLocal,
                            cpn           = dr[cpnColumn].ToString(),
                            userID        = (short)UserInfo.UserId,
                            BomCustVendId = custVenId,
                            enerDay       = DateTime.Now
                        }

                          );
                      i++;
                  }
                  entity.SaveChanges(); }

                MessageBox.Show("Import file " + ofd.FileName + " successfully.");
            }
        }
예제 #11
0
        private void tsbImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Excel文件(*.xls)|*.xls";
            ofd.RestoreDirectory = true;
            ofd.Multiselect      = false;

            if (DialogResult.OK == ofd.ShowDialog())
            {
                DataTable dt = ExcelHelper.ExcelHelper.Import(ofd.FileName);
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                bool hasDc = false, hasMpn = false, hasMfg = false, hasQty = false, hasCost = false, hasResale = false, hasStatus = false, hasNotes = false, hasStockDate = false, hasPacking = false, hasContact = false;
                int  dcColumn = -1, mpnColumn = -1, mfgColumn = -1, qtyColumn = -1, costColumn = -1, resaleColumn = -1, statusColumn = -1, notesColumn = -1, stockDateColumn = -1, packingColumn = -1, contactColumn = -1;
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName.Trim().ToUpper() == "MPN")
                    {
                        hasMpn    = true;
                        mpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "DC" || dc.ColumnName.Trim().ToUpper() == "D/C")
                    {
                        hasDc    = true;
                        dcColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "MFG")
                    {
                        hasMfg    = true;
                        mfgColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "QTY")
                    {
                        hasQty    = true;
                        qtyColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "COST")
                    {
                        hasCost    = true;
                        costColumn = dt.Columns.IndexOf(dc);
                    }

                    if (dc.ColumnName.Trim().ToUpper() == "RESALE")
                    {
                        hasResale    = true;
                        resaleColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "STATUS")
                    {
                        hasStatus    = true;
                        statusColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "NOTES")
                    {
                        hasNotes    = true;
                        notesColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "DATE")
                    {
                        hasStockDate    = true;
                        stockDateColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "PACKING")
                    {
                        hasPacking    = true;
                        packingColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "CONTACT")
                    {
                        hasContact    = true;
                        contactColumn = dt.Columns.IndexOf(dc);
                    }
                }
                if (false == (hasCost && hasMpn && hasDc && hasMfg && hasQty && hasCost && hasResale && hasStatus && hasNotes && hasStockDate && hasPacking && hasContact))
                {
                    MessageBox.Show("Please check the xls File Column.(DC,MPN,MFG,QTY,COST,RESALE,STATUS,NOTES,DATE,PACKING,CONTACT)");
                    return;
                }

                int i = 1;

                StringBuilder sb = new StringBuilder();
                sb.Append("insert into ambleStock(mpn,mfg,dc,qty,resale,cost,packing,contact,statu,notes,stockDate) values ");

                foreach (DataRow dr in dt.Rows)
                {
                    //Qty omit the ","
                    string qtyString = dr[qtyColumn].ToString();
                    qtyString = qtyString.Replace(",", string.Empty);

                    if (!string.IsNullOrWhiteSpace(qtyString) && (!ItemsCheck.CheckIntNumber(qtyString)))
                    {
                        MessageBox.Show("The Qty value is not correct in row " + i.ToString());
                        return;
                    }
                    if (!string.IsNullOrWhiteSpace(dr[resaleColumn].ToString()) && (!ItemsCheck.CheckFloatNumber(dr[resaleColumn])))
                    {
                        MessageBox.Show("The Resale value is not correct in row " + i.ToString());
                        return;
                    }
                    if (!string.IsNullOrWhiteSpace(dr[costColumn].ToString()) && (!ItemsCheck.CheckFloatNumber(dr[costColumn])))
                    {
                        MessageBox.Show("The Cost value is not correct in row " + i.ToString());
                        return;
                    }


                    int?  qtyLocal;
                    float?resaleLocal, costLocal;

                    if (string.IsNullOrWhiteSpace(qtyString))
                    {
                        qtyLocal = null;
                    }
                    else
                    {
                        qtyLocal = Convert.ToInt32(qtyString);
                    }

                    if (string.IsNullOrWhiteSpace(dr[resaleColumn].ToString()))
                    {
                        resaleLocal = null;
                    }
                    else
                    {
                        resaleLocal = Convert.ToSingle(dr[resaleColumn]);
                    }

                    if (string.IsNullOrWhiteSpace(dr[costColumn].ToString()))
                    {
                        costLocal = null;
                    }
                    else
                    {
                        costLocal = Convert.ToSingle(dr[costColumn]);
                    }


                    sb.AppendFormat("('{0}','{1}','{2}',{3},{4},{5},'{6}','{7}','{8}','{9}','{10}'),", dr[mpnColumn].ToString(), dr[mfgColumn].ToString(), dr[dcColumn].ToString(),
                                    qtyLocal.HasValue ? qtyLocal.Value.ToString() : "null", resaleLocal.HasValue ? resaleLocal.Value.ToString() : "null", costLocal.HasValue ? costLocal.Value.ToString() : "null", dr[packingColumn].ToString(), dr[contactColumn].ToString(), dr[statusColumn].ToString(), dr[notesColumn].ToString(), dr[stockDateColumn].ToString());
                }
                string sql = sb.ToString();
                sql = sql.Substring(0, sql.Length - 1);
                db.ExecDataBySql(sql);
            }
            Stock_Load(this, null);
        }