if user click on "Open" button then status should be updated and show as "OPEN" and CLOSING_DATE should be 'NULL' so comp_id visible to user.
COMPLAINT_ID | EMPLOYEE_NAME | COMPLAINT_MESSAGE | COMPLAINT_LODGE_DATE | CLOSING_DATE | REMARKS | STATUS | ATTEND_BY | CLOSING_DATE | |
1053 |
Dharmendra Singh |
PC - Power cable of PC not working. (DM Lab building, ground floor, Civil Hall) |
12/29/2020 9:24:13 AM |
12/29/2020 5:37:58 PM |
- |
Closed |
Select |
12/29/2020 5:37:58 PM |
Open |
namespace gridview_filter
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["Filter"] = "ALL";
BindGrid();
}
}
private void BindGrid()
{
DataTable dt = new DataTable();
String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand("spx_GetOCMS");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Filter", ViewState["Filter"].ToString());
cmd.Connection = con;
sda.SelectCommand = cmd;
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
DropDownList ddlCountry =
(DropDownList)GridView1.HeaderRow.FindControl("ddlCountry");
this.BindCountryList(ddlCountry);
}
protected void CountryChanged(object sender, EventArgs e)
{
DropDownList ddlCountry = (DropDownList)sender;
ViewState["Filter"] = ddlCountry.SelectedValue;
this.BindGrid();
}
private void BindCountryList(DropDownList ddlCountry)
{
String strConnString = System.Configuration.ConfigurationManager
.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand("select distinct STATUS_NAME" + " from complaint_status");
cmd.Connection = con;
con.Open();
ddlCountry.DataSource = cmd.ExecuteReader();
ddlCountry.DataTextField = "STATUS_NAME";
ddlCountry.DataValueField = "STATUS_NAME";
ddlCountry.DataBind();
con.Close();
ddlCountry.Items.FindByValue(ViewState["Filter"].ToString()).Selected = true;
}
protected void OnPaging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.BindGrid();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditButton")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
Response.Redirect("~/WebForm3.aspx?COMP_ID=" + row.Cells[0].Text);
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[8].Text == "Y")
{
(e.Row.FindControl("LinkButton1") as LinkButton).Visible = false;
}
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
CREATE TABLE [dbo].[comp_box] (
[COMP_ID] INT NULL,
[EMP_ID] NVARCHAR (10) NULL,
[COMP_MESSAGE] NVARCHAR (MAX) NULL,
[STATUS_ID] NVARCHAR (10) NULL,
[COMP_LODGE_DATE] DATETIME NOT NULL,
[CLOSING_DATE] DATETIME NULL,
[REMARKS] VARCHAR (255) NULL,
[S_GUID] UNIQUEIDENTIFIER NULL,
[remote_ip] NVARCHAR (50) NULL,
[who] NVARCHAR (50) NULL,
[user_feedback] NVARCHAR (255) NULL,
[type] NVARCHAR (255) NULL,
[ATTEND_DATE] DATETIME NULL,
[ATTEND_BY] VARCHAR (255) NULL
);