Ejemplo n.º 1
0
 public bool CloseDSS(mdlOpenDSS obj_mdlOpenDSS)
 {
     return obj_dalOpenDSS.CloseDSS(obj_mdlOpenDSS);
 }
Ejemplo n.º 2
0
        public bool CloseDSS(mdlOpenDSS obj_mdlOpenDSS)
        {
            bool IsSaved = false;
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            SqlTransaction transaction = con.BeginTransaction();
            try
            {
                for (int i = 0; i <= obj_mdlOpenDSS.dtOpenDSS.Rows.Count -1; i++)
                {
                    if (obj_mdlOpenDSS.dtOpenDSS.Rows[i][0].ToString() == "True")
                    {
                        SqlCommand cmd = new SqlCommand("stp_ERP_OpenDSS_CRUD", con, transaction);
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@Pk_DSSID", SqlDbType.VarChar, 9).Value = obj_mdlOpenDSS.dtOpenDSS.Rows[i]["DSS ID"].ToString();
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateDSS";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();
                        IsSaved = true;

                        cmd.Parameters.Clear();
                        cmd = new SqlCommand("stp_ERP_OpenDSS_CRUD", con, transaction);
                        cmd.Parameters.Add("@Pk_DSSID", SqlDbType.VarChar, 9).Value = obj_mdlOpenDSS.dtOpenDSS.Rows[i]["DSS ID"].ToString();
                        cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "UpdateSaleInvoice";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();
                    }
                }
                IsSaved = true;
                transaction.Commit();
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                IsSaved = true;
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                MessageBox.Show(ex.Message, "ERP - Babar Medicine Company Lahore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                IsSaved = false;
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return IsSaved;
        }