Ejemplo n.º 1
0
        public string Delete(DTODieuKienBaoQuan data)
        {
            try
            {
                string        connect = Provider.Connecting();
                SqlConnection con     = new SqlConnection(connect);
                con.Open();
                SqlTransaction sqlTransaction = con.BeginTransaction();

                string     query = @"delete dbo_DKBQ where DKBQ_ID= " + data.DKBQ_ID + "";
                SqlCommand cmd   = new SqlCommand(query, con);
                cmd.CommandType = CommandType.Text;
                cmd.Transaction = sqlTransaction;
                int result = cmd.ExecuteNonQuery();
                if (result != 1)
                {
                    sqlTransaction.Rollback();
                    sqlTransaction.Dispose();
                    con.Close();
                    return(@"Lỗi số 1 : DAOHoatChat ->Update : Cập nhật dữ liệu đơn vị tính lỗi");
                }

                sqlTransaction.Commit();
                sqlTransaction.Dispose();
                con.Close();
                return("SUCCESS");
            }
            catch (Exception e)
            {
                return(@"Lỗi ngoại lệ : DAOHoatChat ->Delete : " + e.Message);
            }
        }
Ejemplo n.º 2
0
 public string Delete(DTODieuKienBaoQuan data)
 {
     try
     {
         DAODieuKienBaoQuan DKBQ = new DAODieuKienBaoQuan();
         return(DKBQ.Delete(data));
     }
     catch (Exception e)
     {
         return("Lỗi ngoại lệ: BUSHoatChat -> Delete: " + e.Message);
     }
 }
Ejemplo n.º 3
0
        public string Insert(ref DTODieuKienBaoQuan data)
        {
            try
            {
                DAODieuKienBaoQuan DKBQ = new DAODieuKienBaoQuan();

                return(DKBQ.Insert(ref data));
            }
            catch (Exception e)
            {
                return(@"Lỗi ngoại lệ : BUSHoatChat -> Insert : " + e.Message);
            }
        }
Ejemplo n.º 4
0
        public string Insert(ref DTODieuKienBaoQuan data)
        {
            try
            {
                string        connect = Provider.Connecting();
                SqlConnection con     = new SqlConnection(connect);
                con.Open();
                SqlTransaction sqlTransaction = con.BeginTransaction();
                string         query          = @"insert into dbo_DKBQ(DKBQ_Name) values(N'" + data.DKBQ_Name + "')";
                SqlCommand     cmd            = new SqlCommand(query, con);
                cmd.CommandType = CommandType.Text;
                cmd.Transaction = sqlTransaction;
                int result = cmd.ExecuteNonQuery();
                if (result == 1)
                {
                    query = "SELECT IDENT_CURRENT('dbo_DKBQ')";
                    SqlCommand cmdID = new SqlCommand(query, con);
                    cmdID.CommandType = CommandType.Text;
                    cmdID.Transaction = sqlTransaction;

                    object id = cmdID.ExecuteScalar();
                    data.DKBQ_ID = id.ToString();
                    if (result > 0)
                    {
                        sqlTransaction.Commit();
                    }
                    else
                    {
                        sqlTransaction.Rollback();
                        sqlTransaction.Dispose();
                        con.Close();
                        return("Lỗi số 2 : DAODKBQ -> Insert : Lấy mã đơn vị tính lỗi");
                    }
                }
                else
                {
                    sqlTransaction.Rollback();
                    sqlTransaction.Dispose();
                    con.Close();
                    return(@"Lỗi số 1 : DAODKBQ ->Insert : Thêm dữ liệu đơn vị tính lỗi ");
                }
                sqlTransaction.Dispose();
                con.Close();
                return("SUCCESS");
            }
            catch (Exception e)
            {
                return("Lỗi ngoại lệ: DAODKBQ -> Insert: " + e.Message);
            }
        }