Beispiel #1
0
    public static bool delete_Thacmac(thacmac tm)
    {
        bool       success = false;
        SqlCommand cmd     = new SqlCommand("sp_delete_Thacmac", cnn);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@cauhoi", tm.cauhoi);
        cnn.Open();
        SqlTransaction trans = cnn.BeginTransaction("delete_Thacmac");

        try
        {
            cmd.Transaction = trans;
            cmd.ExecuteNonQuery();
            trans.Commit();
            success = true;
        }
        catch (Exception)
        {
            success = false;
            trans.Rollback();
        }
        finally
        {
            if (cnn.State != ConnectionState.Closed)
            {
                cnn.Close();
            }
        }
        return(success);
    }
Beispiel #2
0
 public static bool add_Thacmac(thacmac tm)
 {
     bool success = false;
     SqlCommand cmd = new SqlCommand("sp_add_Thacmac", cnn);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@cauhoi", tm.cauhoi);
     cmd.Parameters.AddWithValue("@cautraloi", tm.cautraloi);
     cmd.Parameters.AddWithValue("@ngaydang", tm.ngaydang);
     cnn.Open();
     SqlTransaction trans = cnn.BeginTransaction("add_Thacmac");
     try
     {
         cmd.Transaction = trans;
         cmd.ExecuteNonQuery();
         trans.Commit();
         success = true;
     }
     catch (Exception)
     {
         success = false;
         trans.Rollback();
     }
     finally
     {
         if (cnn.State != ConnectionState.Closed)
         {
             cnn.Close();
         }
     }
     return success;
 }
Beispiel #3
0
 //----------------------------------------- THẮC MẮC ----------------------------------------------------------------------
 protected void btn_dangnoidungthacmac_Click(object sender, EventArgs e)
 {
     thacmac tm = new thacmac();
     tm.cauhoi = txt_cauhoi.Value;
     tm.cautraloi = txt_cautraloi.Text;
     tm.ngaydang = DateTime.Now;
     bool success = thacmac_Action.add_Thacmac(tm);
     if(success == true)
     {
         Response.Write("<script>alert('Đăng thắc mắc thành công')</script>");
     }
     else
     {
         Response.Write("<script>alert('Đăng thắc mắc không thành công')</script>");
     }
 }
Beispiel #4
0
    protected void grv_thacmac_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string  cauhoi = grv_thacmac.DataKeys[e.RowIndex].Value.ToString();
        thacmac tm     = new thacmac();

        tm.cauhoi = cauhoi;
        bool success = thacmac_Action.delete_Thacmac(tm);

        if (success == true)
        {
            Response.Write("<script>alert('Xóa thắc mắc thành công')</script>");
            grv_thacmac.DataBind();
        }
        else
        {
            Response.Write("<script>alert('Không thể xóa thắc mắc')</script>");
        }
    }
Beispiel #5
0
    //----------------------------------------- THẮC MẮC ----------------------------------------------------------------------
    protected void btn_dangnoidungthacmac_Click(object sender, EventArgs e)
    {
        thacmac tm = new thacmac();

        tm.cauhoi    = txt_cauhoi.Value;
        tm.cautraloi = txt_cautraloi.Text;
        tm.ngaydang  = DateTime.Now;
        bool success = thacmac_Action.add_Thacmac(tm);

        if (success == true)
        {
            Response.Write("<script>alert('Đăng thắc mắc thành công')</script>");
        }
        else
        {
            Response.Write("<script>alert('Đăng thắc mắc không thành công')</script>");
        }
    }
Beispiel #6
0
 protected void grv_thacmac_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     string cauhoi = grv_thacmac.DataKeys[e.RowIndex].Value.ToString();
     thacmac tm = new thacmac();
     tm.cauhoi = cauhoi;
     bool success = thacmac_Action.delete_Thacmac(tm);
     if (success == true)
     {
         Response.Write("<script>alert('Xóa thắc mắc thành công')</script>");
         grv_thacmac.DataBind();
     }
     else
     {
         Response.Write("<script>alert('Không thể xóa thắc mắc')</script>");
     }
 }