private bool SaveProduct()
        {
            try
            {
                TrimTextBoxes();
                if (IsProductValid())
                {
                    Decimal dSalePrice = 0;

                    if (salePriceTextBox.Text != string.Empty)
                    {
                        dSalePrice = Decimal.Parse(salePriceTextBox.Text);
                    }

                    if (IsUpdateMode)
                    {
                        if (taProducts.Update(trProductsRow) > 0)
                        {
                            MessageBox.Show("Product updated successfully", "Product Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(true);
                        }
                        else
                        {
                            MessageBox.Show("Product Updation failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                    else
                    {
                        if (taProducts.Insert(productNameTextBox.Text, descriptionTextBox.Text,
                                              manufacturerTextBox.Text, productTag1TextBox.Text, productTag2TextBox.Text,
                                              dSalePrice, false) > 0)
                        {
                            MessageBox.Show("Product inserted successfully", "Product Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(true);
                        }
                        else
                        {
                            MessageBox.Show("Product insertion failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Product insertion failed due to following error:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
        private void btnImportStock_Click(object sender, EventArgs e)
        {
            string         connString = "Dsn=SageLine50v10;uid=manager;Pwd=eplslrc;";
            OdbcConnection conn       = new OdbcConnection(connString);
            OdbcCommand    comm       = new OdbcCommand();

            comm.Connection     = conn;
            comm.CommandTimeout = 300;
            comm.CommandText    = "SELECT  STOCK_CODE AS ProductName, DESCRIPTION, WEB_DESCRIPTION AS ProductTag1, WEB_DETAILS, WEB_CATEGORY_1, SALES_PRICE, 1 AS Discontinued FROM STOCK";
            conn.Open();

            OdbcDataAdapter da = new OdbcDataAdapter(comm);
            DataSet         ds = new DataSet();

            da.Fill(ds);

            //var prds = this.inventoryStoreDataSet.tblProducts;
            //prds.Merge(ds.Tables[0],true);

            InventoryStoreDataSetTableAdapters.tblProductsTableAdapter taProducts = new InventoryStoreDataSetTableAdapters.tblProductsTableAdapter();
            InventoryStoreDataSet.tblProductsRow trProductsRow;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                trProductsRow = dr as InventoryStoreDataSet.tblProductsRow;

                InventoryStoreDataSet.tblProductsDataTable dt = taProducts.GetProductByID(ProductID);
                if (dt.Rows.Count > 0)
                {
                    trProductsRow = dt.Rows[0] as InventoryStoreDataSet.tblProductsRow;
                }

                if (taProducts.Update(trProductsRow) > 0)
                {
                    //MessageBox.Show("Product updated successfully", "Product Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //return true;
                }
                else
                {
                    taProducts.Insert(dr[0].ToString(), dr[1].ToString(),
                                      dr[2].ToString(), dr[3].ToString(), dr[4].ToString(),
                                      decimal.Parse(dr[5].ToString()), false);
                }
            }

            this.tblProductsTableAdapter.FillActiveProducts(this.inventoryStoreDataSet.tblProducts);
        }