Beispiel #1
0
    public static bool delete_Duan(duan da)
    {
        bool       success = false;
        SqlCommand cmd     = new SqlCommand("sp_delete_Duan", cnn);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@maduan", da.maduan);
        cnn.Open();
        SqlTransaction trans = cnn.BeginTransaction("delete_Baiviet");

        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
    protected void btn_themduan_Click(object sender, EventArgs e)
    {
        duan da = new duan();

        da.maduan        = txt_maduan.Value.ToString();
        da.tenduan       = txt_tenduan.Value.ToString();
        da.makhachhang   = ddl_dskhachhang.SelectedValue.ToString();
        da.boanh         = lbl_thumucanhduan.InnerText.ToString();
        da.ngaykhoicong  = DateTime.Parse(txt_ngaykhoicongduan.Value.ToString()).ToString();
        da.ngayhoanthanh = DateTime.Parse(txt_ngayhoanthanhduan.Value.ToString()).ToString();
        da.dientich      = txt_dientichduan.Value.ToString();
        da.diachi        = txt_diachicongtrinh.Value.ToString();
        bool success = duan_Action.add_Duan(da);

        if (success == true)
        {
            dtl_dsduan.DataSource = duan_Action.getFull_Duan();
            dtl_dsduan.DataBind();
            Response.Write("<script>alert('Thêm dự án mới thành công')</script>");
        }
        else
        {
            Response.Write("<script>alert('Thêm dự án mới không thành công')</script>");
        }
    }
Beispiel #3
0
    protected void dtl_dsduan_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        string argu = e.CommandArgument.ToString();
        duan   da   = new duan();

        da.maduan = argu;
        bool success = duan_Action.delete_Duan(da);

        if (success == true)
        {
            Directory.Delete(Server.MapPath(@"~/duan/" + argu), true);
            Response.Redirect(Request.Url.AbsoluteUri);
        }
        else
        {
            Response.Write("<script>alert('Xóa dự án thất bại')</script>");
        }
    }
Beispiel #4
0
    public static bool add_Duan(duan da)
    {
        bool       success = false;
        SqlCommand cmd     = new SqlCommand("sp_add_Duan", cnn);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@maduan", da.maduan);
        cmd.Parameters.AddWithValue("@tenduan", da.tenduan);
        cmd.Parameters.AddWithValue("@makhachhang", da.makhachhang);
        cmd.Parameters.AddWithValue("@boanh", da.boanh);
        cmd.Parameters.AddWithValue("@ngaykhoicong", da.ngaykhoicong);
        cmd.Parameters.AddWithValue("@ngayhoanthanh", da.ngayhoanthanh);
        cmd.Parameters.AddWithValue("@dientich", da.dientich);
        cmd.Parameters.AddWithValue("@diachi", da.diachi);
        cnn.Open();
        SqlTransaction trans = cnn.BeginTransaction("add_Duan");

        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 #5
0
 public static bool add_Duan(duan da)
 {
     bool success = false;
     SqlCommand cmd = new SqlCommand("sp_add_Duan", cnn);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@maduan", da.maduan);
     cmd.Parameters.AddWithValue("@tenduan", da.tenduan);
     cmd.Parameters.AddWithValue("@makhachhang", da.makhachhang);
     cmd.Parameters.AddWithValue("@boanh", da.boanh);
     cmd.Parameters.AddWithValue("@ngaykhoicong", da.ngaykhoicong);
     cmd.Parameters.AddWithValue("@ngayhoanthanh", da.ngayhoanthanh);
     cmd.Parameters.AddWithValue("@dientich", da.dientich);
     cmd.Parameters.AddWithValue("@diachi", da.diachi);
     cnn.Open();
     SqlTransaction trans = cnn.BeginTransaction("add_Duan");
     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 #6
0
 public static bool delete_Duan(duan da)
 {
     bool success = false;
     SqlCommand cmd = new SqlCommand("sp_delete_Duan", cnn);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@maduan", da.maduan);
     cnn.Open();
     SqlTransaction trans = cnn.BeginTransaction("delete_Baiviet");
     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 #7
0
 protected void dtl_dsduan_DeleteCommand(object source, DataListCommandEventArgs e)
 {
     string argu = e.CommandArgument.ToString();
     duan da = new duan();
     da.maduan = argu;
     bool success = duan_Action.delete_Duan(da);
     if (success == true)
     {
         Directory.Delete(Server.MapPath(@"~/duan/" + argu), true);
         Response.Redirect(Request.Url.AbsoluteUri);
     }
     else
     {
         Response.Write("<script>alert('Xóa dự án thất bại')</script>");
     }
 }
Beispiel #8
0
 protected void btn_themduan_Click(object sender, EventArgs e)
 {
     duan da = new duan();
     da.maduan = txt_maduan.Value.ToString();
     da.tenduan = txt_tenduan.Value.ToString();
     da.makhachhang = ddl_dskhachhang.SelectedValue.ToString();
     da.boanh = lbl_thumucanhduan.InnerText.ToString();
     da.ngaykhoicong = DateTime.Parse(txt_ngaykhoicongduan.Value.ToString()).ToString();
     da.ngayhoanthanh = DateTime.Parse(txt_ngayhoanthanhduan.Value.ToString()).ToString();
     da.dientich = txt_dientichduan.Value.ToString();
     da.diachi = txt_diachicongtrinh.Value.ToString();
     bool success = duan_Action.add_Duan(da);
     if (success == true)
     {
         dtl_dsduan.DataSource = duan_Action.getFull_Duan();
         dtl_dsduan.DataBind();
         Response.Write("<script>alert('Thêm dự án mới thành công')</script>");
     }
     else
     {
         Response.Write("<script>alert('Thêm dự án mới không thành công')</script>");
     }
 }