Beispiel #1
0
 public bool UpdateCompanyWiseBatch(mdlBatchCorrection obj_mdlBatchCorrection)
 {
     return obj_dalBatchCorrection.UpdateCompanyWiseBatch(obj_mdlBatchCorrection);
 }
Beispiel #2
0
 public bool SaveBatch(mdlBatchCorrection obj_mdlBatchCorrection, string ProductID)
 {
     return obj_dalBatchCorrection.SaveBatch(obj_mdlBatchCorrection, ProductID);
 }
Beispiel #3
0
        public bool UpdateCompanyWiseBatch(mdlBatchCorrection obj_mdlBatchCorrection)
        {
            bool isUpdated = false;
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            SqlTransaction transaction = con.BeginTransaction();
            SqlCommand cmd = new SqlCommand();
            try
            {
                for (int i = 0; i <= obj_mdlBatchCorrection.dtBatchCorrection.Rows.Count - 1; i++)
                {
                    double Ln_BlockedQty = 0;
                    Ln_BlockedQty = Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString()) - Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Block"].ToString());
                    if (Ln_BlockedQty > 0)
                    {
                        cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                        cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                        cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                        cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                        cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                       // cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Select";
                        dr_Reader = cmd.ExecuteReader();
                        if (dr_Reader.Read())
                        {
                            if (!dr_Reader.IsClosed)
                            {
                                dr_Reader.Close();
                            }
                            cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                            cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0.0000;
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                            cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQtyP";
                            cmd.ExecuteNonQuery();
                        }
                        else
                        {
                            if (!dr_Reader.IsClosed)
                            {
                                dr_Reader.Close();
                            }
                            cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                            cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                            cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Save";
                            cmd.ExecuteNonQuery();
                        }
                        cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                        cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                        cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQty";
                        cmd.ExecuteNonQuery();
                    }

                    else if (Ln_BlockedQty < 0)
                    {
                        //Ln_BlockedQty = Ln_BlockedQty * (-1);

                        cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                        cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                        cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                        cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                        cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                       // cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Select";
                        dr_Reader = cmd.ExecuteReader();
                        if (dr_Reader.Read())
                        {
                            if (!dr_Reader.IsClosed)
                            {
                                dr_Reader.Close();
                            }

                            //cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            //cmd.CommandType = CommandType.StoredProcedure;
                            //cmd.Parameters.Clear();
                            //cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                            //cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            //cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            //cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            //cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            //cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                            //cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            //cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                            //cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            //cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQtyM";
                            //cmd.ExecuteNonQuery();

                            cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                            cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                            cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQtyP";
                            cmd.ExecuteNonQuery();
                        }
                        else
                        {
                            if (!dr_Reader.IsClosed)
                            {
                                dr_Reader.Close();
                            }
                            cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["ID"].ToString();
                            cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                            cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Save";
                            cmd.ExecuteNonQuery();
                        }
                        cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                        cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                        cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQty";
                        cmd.ExecuteNonQuery();
                    }

                }
                transaction.Commit();
                isUpdated = true;
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                isUpdated = false;
                MessageBox.Show(ex.Message, "Babar Medicine Company Lahore - ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return isUpdated;
        }
Beispiel #4
0
        public bool SaveNewBatchAdjustmentInformation(mdlBatchCorrection obj_mdlBatchCorrection, SqlCommand cmd, SqlTransaction transaction, string ProductId, string AdjType, string StockType, double AdjQty, string Priority)
        {
            bool functionReturnValue = false;
            cmd.Parameters.Clear();
            cmd = new SqlCommand("stp_ERP_BatchAdjustments_CRUD", con, transaction);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@pk_BatchAdjustmentId", SqlDbType.VarChar, 6).Value = L_MaxBatchAdjId;
            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Select";
            //if (dr_Reader.IsClosed)
            //{
            //    dr_Reader.Close();
            //}
            //if(con.State == ConnectionState.Open)
            //{
            //    con.Close();
            //}
            //con.Open();
            dr_Reader = cmd.ExecuteReader();

            if (dr_Reader.HasRows)
            {
                if (dr_Reader.Read())
                {
                    L_MaxBatchAdjId = string.Format("{0:000000}", Convert.ToDouble(dr_Reader.GetValue(0)));
                }
                if (!dr_Reader.IsClosed)
                {
                    dr_Reader.Close();
                }
                functionReturnValue = SaveNewBatchAdjustmentDetials(obj_mdlBatchCorrection, cmd, transaction, L_MaxBatchAdjId, AdjType, StockType, AdjQty, Priority);
            }
            else
            {
                if (!dr_Reader.IsClosed)
                {
                    dr_Reader.Close();
                }
                //L_MaxBatchAdjId = GetMaxBatchAdjustmentId();
                cmd.Parameters.Clear();
                cmd = new SqlCommand("stp_ERP_BatchAdjustments_CRUD", con, transaction);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@pk_BatchAdjustmentId", SqlDbType.VarChar, 6).Value = L_MaxBatchAdjId;
                cmd.Parameters.Add("@BatchAdjustmentDate", SqlDbType.DateTime).Value = obj_mdlBatchCorrection.AdjustmentDate;
                cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                cmd.Parameters.Add("@AddUser", SqlDbType.VarChar, 16).Value = obj_mdlBatchCorrection.AddUser;
                cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 16).Value = "Save";
                if (cmd.ExecuteNonQuery() != 0)
                {
                    cmd.Parameters.Clear();
                    cmd = new SqlCommand("stp_ERP_BatchAdjustments_CRUD", con, transaction);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@pk_BatchAdjustmentId", SqlDbType.VarChar, 6).Value = L_MaxBatchAdjId;
                    cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 16).Value = "Update";
                    cmd.ExecuteNonQuery();
                    functionReturnValue = SaveNewBatchAdjustmentDetials(obj_mdlBatchCorrection, cmd, transaction, L_MaxBatchAdjId, AdjType, StockType, AdjQty, Priority);
                    //transaction.Commit();
                    functionReturnValue = true;
                }
                else
                {
                    RollBack = true;
                    functionReturnValue = false;
                }
            }
            //cmd.Cancel();
            //cmd.Dispose();
            return functionReturnValue;
        }
Beispiel #5
0
 public bool SaveNewBatchAdjustmentDetials(mdlBatchCorrection obj_mdlBatchCorrection, SqlCommand cmd, SqlTransaction transaction, string MaxBatchAdjId, string AdjType, string StockType, double AdjQty, string Priority)
 {
     bool functionReturnValue = false;
     int a = 0;
     for (int i = 0; i <= obj_mdlBatchCorrection.dtBatchCorrection.Rows.Count - 1; i++)
     {
         if (!(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i].RowState == DataRowState.Deleted))
         {
             if (!string.IsNullOrEmpty(Strings.Trim(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString())) & Convert.ToDouble(AdjQty) != 0)
             {
                 if (obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString() == Priority)
                 {
                     cmd.Parameters.Clear();
                     cmd = new SqlCommand("stp_ERP_BatchAdjustment_Details", con, transaction);
                     cmd.CommandType = CommandType.StoredProcedure;
                     cmd.Parameters.Add("@BatchAdjId", SqlDbType.VarChar, 6).Value = MaxBatchAdjId;
                     cmd.Parameters.Add("@AdjType", SqlDbType.VarChar, 6).Value = AdjType;
                     cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 10).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                     cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                     cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                     cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                     cmd.Parameters.Add("@AvaiableQty", SqlDbType.Decimal).Value = 0;
                     cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                     cmd.Parameters.Add("@Quantity", SqlDbType.Decimal).Value = AdjQty;
                     cmd.Parameters.Add("@SaleTax", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["S.Tax Value"].ToString();
                     cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString(); ;
                     a = cmd.ExecuteNonQuery();
                     functionReturnValue = true;
                 }
             }
         }
     }
     if (a != 0)
     {
         functionReturnValue = true;
     }
     else
     {
         RollBack = true;
         functionReturnValue = false;
     }
     return functionReturnValue;
 }
Beispiel #6
0
        public bool SaveBatch(mdlBatchCorrection obj_mdlBatchCorrection, string ProductId)
        {
            int SType = 0;
            string StockType = "";
            string AdjType = "";
            double AdjQty = 0;
            //bool Lc_UpdateDefault = false;
            //double Ln_UnitPrice = 0;
            //double Ln_OldBonusValue = 0;
            //double Ln_NewBonusValue = 0;
            //double Lc_DiffValue = 0;
            bool SaveBatch = false;
            //GetMaxBatchAdjustmentId();

            L_MaxBatchAdjId = GetMaxBatchAdjustmentId();
            //ye wese e hai. jhunga code.
            if(SType == 4)
            {

            }
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            SqlTransaction transaction = con.BeginTransaction();
            try
            {
                SqlCommand cmd = new SqlCommand();
                for (int i = 0; i <= obj_mdlBatchCorrection.dtBatchCorrection.Rows.Count - 1; i++)
                {
                    if (obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString() == "Bonus")
                    {
                        SType = 1;
                        StockType = "Bonus";
                    }
                    else
                    {
                        SType = 0;
                        StockType = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                    }
                    if (Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString()) != Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Qty"].ToString()))
                    {
                        if (Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString()) > Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Qty"].ToString()))
                        {
                            AdjType = "In";
                            AdjQty = (Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Qty"].ToString()) - Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString())) * -1;

                            if (SaveNewBatchAdjustmentInformation(obj_mdlBatchCorrection, cmd, transaction, ProductId, AdjType, StockType, AdjQty, obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString()))
                            {
                                if (obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString() != "")
                                {
                                    cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                                    cmd.CommandType = CommandType.StoredProcedure;
                                    cmd.Parameters.Clear();
                                    cmd.Parameters.Add("@BalanceQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString();
                                    cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                                    cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBalanceQty";
                                    cmd.ExecuteNonQuery();
                                }
                                else
                                {
                                    cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                                    cmd.CommandType = CommandType.StoredProcedure;
                                    cmd.Parameters.Clear();
                                    cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                                    cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                                    cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                                    cmd.Parameters.Add("@ManufactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                                    cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                                    cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                                    cmd.Parameters.Add("@BalanceQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString();
                                    cmd.Parameters.Add("@QtyFrom", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty From"].ToString();
                                    cmd.Parameters.Add("@QtyTo", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty To"].ToString();
                                    cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                                    cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                                    cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                                    cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Save";
                                    cmd.ExecuteNonQuery();
                                }
                            }
                        }

                        if (Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString()) < Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Qty"].ToString()))
                        {
                            AdjType = "Out";
                            AdjQty = Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Qty"].ToString()) - Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString());
                            if (SaveNewBatchAdjustmentInformation(obj_mdlBatchCorrection, cmd, transaction, ProductId, AdjType, StockType, AdjQty, obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString()))
                            {
                                cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Clear();
                                cmd.Parameters.Add("@BalanceQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Balance Qty"].ToString();
                                cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                                cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBalanceQty";
                                cmd.ExecuteNonQuery();
                            }
                        }
                    }

                    //**********************************************************
                    if (Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString()) != Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Block"].ToString()))
                    {
                        double Ln_BlockedQty = 0;
                        Ln_BlockedQty = Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString()) - Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Old Block"].ToString());
                        //***************** Add Qty In Blocked Batches Information
                        if (Ln_BlockedQty > 0)
                        {
                            cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                            cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Select";
                            if (!dr_Reader.IsClosed)
                            {
                                dr_Reader.Close();
                            }
                            dr_Reader = cmd.ExecuteReader();
                            if (dr_Reader.Read())
                            {
                                if (!dr_Reader.IsClosed)
                                {
                                    dr_Reader.Close();
                                }
                                cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Clear();
                                cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                                cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                                cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                                cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                                cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                                cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                                cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = Ln_BlockedQty;
                                cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                                cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                                cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                                cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQtyP";
                                cmd.ExecuteNonQuery();
                            }
                            else
                            {
                                if (!dr_Reader.IsClosed)
                                {
                                    dr_Reader.Close();
                                }
                                cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Clear();
                                cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                                cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                                cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                                cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                                cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                                cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                                cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = Ln_BlockedQty;
                                cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                                cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                                cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                                cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Save";
                                cmd.ExecuteNonQuery();
                            }

                            cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQty";
                            cmd.ExecuteNonQuery();
                        }
                        else if (Ln_BlockedQty < 0)
                        {
                            cmd = new SqlCommand("stp_ERP_BlockBatches_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                            cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                            cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                            cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                            cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                            cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = Ln_BlockedQty;
                            cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQtyM";
                            cmd.ExecuteNonQuery();

                            cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@BlockQty", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Block Qty"].ToString();
                            cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                            cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                            cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateBlockQty";
                            cmd.ExecuteNonQuery();
                        }
                    }

                    //**********************************************************

                    cmd = new SqlCommand("stp_ERP_InvoiceBatch_CRUD", con, transaction);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                    cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                    cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                    cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                    cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                    cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                    cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Select";

                    dr_Reader = cmd.ExecuteReader();
                    if (dr_Reader.Read())
                    {
                        if (!dr_Reader.IsClosed)
                        {
                            dr_Reader.Close();
                        }
                        cmd = new SqlCommand("stp_ERP_InvoiceBatch_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                        cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                        cmd.Parameters.Add("@QtyTo", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty To"].ToString();
                        cmd.Parameters.Add("@QtyFrom", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty From"].ToString();
                        cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                        cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                        cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                        cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateQtyFrom";
                        cmd.ExecuteNonQuery();

                    }
                    else if (Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty From"].ToString()) != 0 & Convert.ToDouble(obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty To"].ToString()) != 0)
                    {
                        if (!dr_Reader.IsClosed)
                        {
                            dr_Reader.Close();
                        }
                        cmd = new SqlCommand("stp_ERP_InvoiceBatch_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = ProductId;
                        cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Batch No"].ToString();
                        cmd.Parameters.Add("@QtyTo", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty To"].ToString();
                        cmd.Parameters.Add("@QtyFrom", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty From"].ToString();
                        cmd.Parameters.Add("@ExpiryDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Exp. Date"].ToString();
                        cmd.Parameters.Add("@ManfactureDate", SqlDbType.VarChar, 20).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Mfg. Date"].ToString();
                        cmd.Parameters.Add("@TP", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["TP"].ToString();
                        cmd.Parameters.Add("@STaxValue", SqlDbType.Decimal).Value = 0;
                        cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 50).Value = "Remarks";//obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Remarks"].ToString();
                        cmd.Parameters.Add("@CostRate", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Cost Rate"].ToString();
                        cmd.Parameters.Add("@StockType", SqlDbType.VarChar, 50).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Type"].ToString();
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Save";
                        cmd.ExecuteNonQuery();
                    }
                    if (obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString() != "")
                    {
                        if (!dr_Reader.IsClosed)
                        {
                            dr_Reader.Close();
                        }
                        cmd.Parameters.Clear();
                        cmd = new SqlCommand("stp_ERP_BatchCorrection_CRUD", con, transaction);
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@QtyFrom", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty From"].ToString();
                        cmd.Parameters.Add("@QtyTo", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Qty To"].ToString();
                        // cmd.Parameters.Add("@Block", SqlDbType.Bit).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["InvBlock"].ToString();
                        cmd.Parameters.Add("@Priority", SqlDbType.Decimal).Value = obj_mdlBatchCorrection.dtBatchCorrection.Rows[i]["Priority"].ToString();
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateQtyFrom";
                        cmd.ExecuteNonQuery();
                    }
                }
                if (!RollBack)
                {
                    transaction.Commit();
                    SaveBatch = true;
                    cmd.Cancel();
                    cmd.Dispose();
                }
                else
                {
                    transaction.Rollback();
                    SaveBatch = false;
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                SaveBatch = false;
                MessageBox.Show(ex.Message, "Babar Medicine Company Lahore - ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return SaveBatch;
        }