using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Test
{
public partial class ShowIT : System.Web.UI.Page
{
string connectiondb = @"Data Source=ARTEMIS\SQL2014;Initial Catalog=SvlITDB;User ID=it;Password=Tigers1234;";
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection sqlcon = new SqlConnection(connectiondb))
{
sqlcon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT c.CaseKey, c.CaseCode, ct.Name, c.CaseName, c.CaseDetail, c.CaseDT, c.Requester, u.DeptName, u.Tel, cs.Name AS Expr1, ic.StaffName, ic.Solve, ic.Dates, ic.ExpectedDT FROM [Case] AS c LEFT OUTER JOIN CaseType AS ct ON c.CaseTypeKey = ct.CaseTypeKey LEFT JOIN Usr AS u ON c.UsrKey = u.UsrKey LEFT JOIN CaseStatus AS cs ON c.CaseStatusKey = cs.CaseStatusKey LEFT OUTER JOIN ItCase AS ic ON c.CaseKey = ic.CaseKey ORDER BY c.CaseKey DESC", sqlcon);
DataTable aaa = new DataTable();
sqlda.Fill(aaa);
GridView1.DataSource = aaa;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.Text == "1") {
using (SqlConnection sqlcon = new SqlConnection(connectiondb))
{
sqlcon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT c.CaseKey, c.CaseCode, ct.Name, c.CaseName, c.CaseDetail, c.CaseDT, c.Requester, u.DeptName, u.Tel, cs.Name AS Expr1, ic.StaffName, ic.Solve, ic.Dates, ic.ExpectedDT FROM [Case] AS c LEFT OUTER JOIN CaseType AS ct ON c.CaseTypeKey = ct.CaseTypeKey LEFT JOIN Usr AS u ON c.UsrKey = u.UsrKey LEFT JOIN CaseStatus AS cs ON c.CaseStatusKey = cs.CaseStatusKey LEFT OUTER JOIN ItCase AS ic ON c.CaseKey = ic.CaseKey WHERE cs.Name = 'Process' ORDER BY c.CaseKey DESC", sqlcon);
DataTable aaa = new DataTable();
sqlda.Fill(aaa);
GridView1.DataSource = aaa;
GridView1.DataBind();
}
}
if (DropDownList1.Text=="2") {
using (SqlConnection sqlcon = new SqlConnection(connectiondb))
{
sqlcon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT c.CaseKey, c.CaseCode, ct.Name, c.CaseName, c.CaseDetail, c.CaseDT, c.Requester, u.DeptName, u.Tel, cs.Name AS Expr1, ic.StaffName, ic.Solve, ic.Dates, ic.ExpectedDT FROM [Case] AS c LEFT OUTER JOIN CaseType AS ct ON c.CaseTypeKey = ct.CaseTypeKey LEFT JOIN Usr AS u ON c.UsrKey = u.UsrKey LEFT JOIN CaseStatus AS cs ON c.CaseStatusKey = cs.CaseStatusKey LEFT OUTER JOIN ItCase AS ic ON c.CaseKey = ic.CaseKey WHERE cs.Name = 'Success' ORDER BY c.CaseKey DESC", sqlcon);
DataTable aaa = new DataTable();
sqlda.Fill(aaa);
GridView1.DataSource = aaa;
GridView1.DataBind();
}
}
if (DropDownList1.Text == "3") {
using (SqlConnection sqlcon = new SqlConnection(connectiondb))
{
sqlcon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT c.CaseKey, c.CaseCode, ct.Name, c.CaseName, c.CaseDetail, c.CaseDT, c.Requester, u.DeptName, u.Tel, cs.Name AS Expr1, ic.StaffName, ic.Solve, ic.Dates, ic.ExpectedDT FROM [Case] AS c LEFT OUTER JOIN CaseType AS ct ON c.CaseTypeKey = ct.CaseTypeKey LEFT JOIN Usr AS u ON c.UsrKey = u.UsrKey LEFT JOIN CaseStatus AS cs ON c.CaseStatusKey = cs.CaseStatusKey LEFT OUTER JOIN ItCase AS ic ON c.CaseKey = ic.CaseKey ORDER BY c.CaseKey DESC", sqlcon);
DataTable aaa = new DataTable();
sqlda.Fill(aaa);
GridView1.DataSource = aaa;
GridView1.DataBind();
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
using (SqlConnection sqlcon = new SqlConnection(connectiondb))
{
sqlcon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT c.CaseKey, c.CaseCode, ct.Name, c.CaseName, c.CaseDetail, c.CaseDT, c.Requester, u.DeptName, u.Tel, cs.Name AS Expr1, ic.StaffName, ic.Solve, ic.Dates, ic.ExpectedDT FROM [Case] AS c LEFT OUTER JOIN CaseType AS ct ON c.CaseTypeKey = ct.CaseTypeKey LEFT JOIN Usr AS u ON c.UsrKey = u.UsrKey LEFT JOIN CaseStatus AS cs ON c.CaseStatusKey = cs.CaseStatusKey LEFT OUTER JOIN ItCase AS ic ON c.CaseKey = ic.CaseKey Where c.CaseCode LIKE '%' +'"+TextBox1.Text.Trim()+"'+'%' ", sqlcon);
DataTable aaa = new DataTable();
sqlda.Fill(aaa);
GridView1.DataSource = aaa;
GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow gr = GridView1.SelectedRow;
Response.Redirect("TestEdit.aspx?CaseKey=" + gr.Cells[1].Text + "&CaseCode=" + gr.Cells[2].Text + "&ct.Name=" + gr.Cells[3].Text + "&CaseName=" + gr.Cells[4].Text + "&CaseDetail=" + gr.Cells[5].Text + "&CaseDT=" + gr.Cells[6].Text + "&Requester=" + gr.Cells[7].Text + "&DeptName=" + gr.Cells[8] + "cs.Tel" + gr.Cells[9] + "cs.Name" + gr.Cells[10] + "StaffName" + gr.Cells[11] + "Solve" + gr.Cells[12] + "Dates" + gr.Cells[13] + "ExpectedDT" + gr.Cells[14]);
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
using (SqlConnection sqlcon = new SqlConnection(connectiondb))
{
sqlcon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT c.CaseKey, c.CaseCode, ct.Name, c.CaseName, c.CaseDetail, c.CaseDT, c.Requester, u.DeptName, u.Tel, cs.Name AS Expr1, ic.StaffName, ic.Solve, ic.Dates, ic.ExpectedDT FROM [Case] AS c LEFT OUTER JOIN CaseType AS ct ON c.CaseTypeKey = ct.CaseTypeKey LEFT JOIN Usr AS u ON c.UsrKey = u.UsrKey LEFT JOIN CaseStatus AS cs ON c.CaseStatusKey = cs.CaseStatusKey LEFT OUTER JOIN ItCase AS ic ON c.CaseKey = ic.CaseKey ORDER BY c.CaseKey DESC", sqlcon);
DataTable aaa = new DataTable();
sqlda.Fill(aaa);
GridView1.DataSource = aaa;
GridView1.DataBind();
}
}
}