private string TransferStock()
        {
            string _BillNumber = "";

            if (Bill_ID.Trim().Length == 0)
            {
                _BillNumber = GenerateBillNumber();

                ObjDAL.SetColumnData("BillNo", SqlDbType.NVarChar, _BillNumber);
                ObjDAL.SetColumnData("FromStore", SqlDbType.Int, cmdFrom.SelectedValue);
                ObjDAL.SetColumnData("ToStore", SqlDbType.Int, cmdTo.SelectedValue);
                ObjDAL.SetColumnData("BillStatus", SqlDbType.NVarChar, lblBillStatus.Text);
                ObjDAL.SetColumnData("TotalQTY", SqlDbType.Int, txtTotalQTY.Text);
                ObjDAL.SetColumnData("BillDate", SqlDbType.Date, dtpSalesDate.Value.ToString("yyyy-MM-dd"));
                ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID);

                int TransferID = ObjDAL.InsertData(clsUtility.DBName + ".dbo.tblStoreTransferBillDetails", true);

                if (TransferID > 0)
                {
                    for (int i = 0; i < dgvProductDetails.Rows.Count; i++)
                    {
                        string Total        = dgvProductDetails.Rows[i].Cells["Total"].Value.ToString();
                        string ProductID    = dgvProductDetails.Rows[i].Cells["ProductID"].Value.ToString();
                        string QTY          = dgvProductDetails.Rows[i].Cells["BillQTY"].Value.ToString();
                        string Rate         = dgvProductDetails.Rows[i].Cells["Rate"].Value.ToString();
                        string ColorID      = dgvProductDetails.Rows[i].Cells["ColorID"].Value.ToString();
                        string SizeID       = dgvProductDetails.Rows[i].Cells["SizeID"].Value.ToString();
                        string BarcodeNo    = dgvProductDetails.Rows[i].Cells["BarcodeNo"].Value.ToString();
                        string SubProductID = dgvProductDetails.Rows[i].Cells["SubProductID"].Value.ToString();

                        ObjDAL.SetColumnData("StoreBillDetailsID", SqlDbType.Int, TransferID);

                        ObjDAL.SetColumnData("ProductID", SqlDbType.Int, ProductID);
                        ObjDAL.SetColumnData("Barcode", SqlDbType.NVarChar, BarcodeNo);
                        ObjDAL.SetColumnData("SubProductID", SqlDbType.Int, SubProductID);
                        ObjDAL.SetColumnData("Rate", SqlDbType.Decimal, Rate);
                        ObjDAL.SetColumnData("BillQTY", SqlDbType.Int, QTY);
                        ObjDAL.SetColumnData("ColorID", SqlDbType.Int, ColorID);
                        ObjDAL.SetColumnData("SizeID", SqlDbType.Int, SizeID);
                        ObjDAL.SetColumnData("Total", SqlDbType.Decimal, Total);
                        ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID);

                        ObjDAL.InsertData(clsUtility.DBName + ".dbo.tblStoreTransferItemDetails", false);
                    }
                    clsUtility.ShowInfoMessage("Item has been transferd to selected store.", clsUtility.strProjectTitle);
                }
            }
            else
            {
                _BillNumber = txtInvoiceNumber.Text;
                ObjDAL.UpdateColumnData("UpdatedOn", SqlDbType.DateTime, DateTime.Now);
                ObjDAL.UpdateColumnData("UpdatedBy", SqlDbType.Int, clsUtility.LoginID);
                ObjDAL.UpdateData(clsUtility.DBName + ".dbo.tblStoreTransferBillDetails", "StoreTransferID='" + Bill_ID + "'");

                ObjDAL.ExecuteNonQuery("Delete " + clsUtility.DBName + ".dbo.tblStoreTransferItemDetails WHERE StoreBillDetailsID=" + Bill_ID);
                int pBillQTY = 0;
                for (int i = 0; i < dgvProductDetails.Rows.Count; i++)
                {
                    string Total     = dgvProductDetails.Rows[i].Cells["Total"].Value.ToString();
                    string ProductID = dgvProductDetails.Rows[i].Cells["ProductID"].Value.ToString();

                    string QTY = dgvProductDetails.Rows[i].Cells["BillQTY"].Value.ToString();
                    pBillQTY += Convert.ToInt32(QTY);

                    string Rate         = dgvProductDetails.Rows[i].Cells["Rate"].Value.ToString();
                    string ColorID      = dgvProductDetails.Rows[i].Cells["ColorID"].Value.ToString();
                    string SizeID       = dgvProductDetails.Rows[i].Cells["SizeID"].Value.ToString();
                    string BarcodeNo    = dgvProductDetails.Rows[i].Cells["BarcodeNo"].Value.ToString();
                    string SubProductID = dgvProductDetails.Rows[i].Cells["SubProductID"].Value.ToString();
                    ObjDAL.SetColumnData("StoreBillDetailsID", SqlDbType.Int, Bill_ID);

                    ObjDAL.SetColumnData("ProductID", SqlDbType.Int, ProductID);
                    ObjDAL.SetColumnData("Barcode", SqlDbType.NVarChar, BarcodeNo);
                    ObjDAL.SetColumnData("SubProductID", SqlDbType.Int, SubProductID);
                    ObjDAL.SetColumnData("Rate", SqlDbType.Decimal, Rate);
                    ObjDAL.SetColumnData("BillQTY", SqlDbType.Int, QTY);
                    ObjDAL.SetColumnData("ColorID", SqlDbType.Int, ColorID);
                    ObjDAL.SetColumnData("SizeID", SqlDbType.Int, SizeID);
                    ObjDAL.SetColumnData("Total", SqlDbType.Decimal, Total);
                    ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID);

                    ObjDAL.InsertData(clsUtility.DBName + ".dbo.tblStoreTransferItemDetails", false);
                }
                ObjDAL.UpdateColumnData("TotalQTY", SqlDbType.Int, pBillQTY);
                ObjDAL.UpdateColumnData("UpdatedOn", SqlDbType.DateTime, DateTime.Now);
                ObjDAL.UpdateColumnData("UpdatedBy", SqlDbType.Int, clsUtility.LoginID);
                ObjDAL.UpdateData(clsUtility.DBName + ".dbo.tblStoreTransferBillDetails", "StoreTransferID='" + Bill_ID + "'");

                clsUtility.ShowInfoMessage("Item has been transferd to selected store.", clsUtility.strProjectTitle);
            }

            return(_BillNumber);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int   n, QTY;
            float price = 0;

            if (textBox3.Text != "" && textBox2.Text != "")
            {
                int.TryParse(textBox3.Text, out QTY);
                price  = Units_Cost * QTY;
                profit = profit * QTY;
                if (Check == false)
                {
                    newValue();
                }
                if (Stock == false)
                {
                    f_profit += profit;
                    total    += price;
                    n         = dataGridView1.Rows.Add();
                    dataGridView1.Rows[n].Cells[0].Value = textBox2.Text;
                    dataGridView1.Rows[n].Cells[1].Value = label6.Text;
                    dataGridView1.Rows[n].Cells[2].Value = textBox3.Text;
                    dataGridView1.Rows[n].Cells[3].Value = price.ToString();
                    string          con  = "server=localhost;user id=root;database=weerodara";
                    MySqlConnection conn = new MySqlConnection(con);
                    conn.Open();
                    string       add1    = "INSERT INTO `Order_SET`( `Bill_No`, `Item_Number`, `QTY`, `Price`, `Date`, `Wholesale or Retail`, `Profits`) VALUES ('" + Bill_ID.ToString() + "','" + item_no.ToString() + "','" + textBox3.Text + "','" + price.ToString() + "','" + Bill_No1.ToString() + "', 'Wholesale', " + profit + ")";
                    MySqlCommand camadd1 = new MySqlCommand(add1, conn);
                    camadd1.ExecuteNonQuery();
                    string       add    = "UPDATE `stock_details` SET `Number_Of_Units`='" + New_QTY.ToString() + "' WHERE `Item_number`='" + item_no.ToString() + "'";
                    MySqlCommand camadd = new MySqlCommand(add, conn);
                    camadd.ExecuteNonQuery();
                    MessageBox.Show("Stock Table Updated & Orders Table rowa insert", "System Ditails");
                    formClear();
                    label13.Visible = true;
                    label13.Text    = total.ToString();

                    conn.Close();
                }
            }
        }