Пример #1
0
    protected void GridServiceCall_Sorting(object sender, GridViewSortEventArgs e)
    {
        ViewState["sortexpression"] = e.SortExpression;
        if (ViewState["sortdirection"] == null)
        {
            ViewState["sortdirection"] = "asc";
        }
        else
        {
            if (ViewState["sortdirection"].ToString() == "asc")
            {
                ViewState["sortdirection"] = "desc";
            }
            else
            {
                ViewState["sortdirection"] = "asc";
            }
        }
        DataTable dtable = new DataTable();

        dtable = (DataTable)Session["data"];
        DataView dview = dtable.DefaultView;

        if (ViewState["sortexpression"] != null)
        {
            dview.Sort = ViewState["sortexpression"].ToString() + " " + ViewState["sortdirection"].ToString();
        }
        GridServiceCall.DataSource = dview;
        GridServiceCall.DataBind();
    }
Пример #2
0
    public void selectservicecall()
    {
        lblBusiness.Text         = ddlWarehouse.SelectedItem.Text;
        lblfromdateprint.Text    = txtFromDate.Text;
        lbltodateprint.Text      = txtTodate.Text;
        lblstatusprint.Text      = ddlMainStatus.SelectedItem.Text;
        lblnamephoneprint.Text   = txtname.Text;
        lblproblemtypeprint.Text = ddlseacrchbyproblemtype.SelectedItem.Text;

        string attch = "";

        if (ddlWarehouse.SelectedIndex > 0)
        {
            attch = " Party_master.id='" + Session["comid"] + "' and Party_master.Whid='" + ddlWarehouse.SelectedValue + "' ";
        }
        else
        {
            attch = " Party_master.id='" + Session["comid"] + "'  ";
        }
        string probtype = "";

        if (ddlseacrchbyproblemtype.SelectedIndex > 0)
        {
            probtype = "and CustomerServiceCallMaster.ProblemTypeId='" + ddlseacrchbyproblemtype.SelectedValue + "'";
        }

        string str2 = "";

        if (ddlMainStatus.SelectedIndex > 0 && txtname.Text != "")
        {
            s = " WareHouseMaster.Name as Wname,  ServiceStatusMaster.StatusName AS Servicestatus, CustomerServiceCallMaster.CustomerServiceCallMasterId,  " +
                " CustomerServiceCallMaster.Entrydate, CustomerServiceCallMaster.ProblemTitle, CustomerServiceCallMaster.ProblemDescription,  " +
                " CustomerServiceCallMaster.ProblemType, CustomerServiceCallMaster.CustomerId, CustomerServiceCallMaster.ServiceStatusId,  " +
                " Party_master.Compname, Party_master.Contactperson, Party_master.Contactperson as comp,ProblemTypeMaster.ProblemName " +
                " FROM         CustomerServiceCallMaster INNER JOIN " +
                " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId " +
                " WHERE    (ServiceStatusMaster.StatusId = '" + ddlMainStatus.SelectedValue + "') and " + attch + " and (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " +
                " " + probtype + "  and Party_master.Contactperson like'" + txtname.Text + "%' or Party_master.Phoneno ='" + txtname.Text + "' or Party_master.Email ='" + txtname.Text + "'";

            str2 = " select count(CustomerServiceCallMaster.CustomerServiceCallMasterId) as ci " +
                   " FROM         CustomerServiceCallMaster INNER JOIN " +
                   " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                   " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                   " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId " +
                   " WHERE    (ServiceStatusMaster.StatusId = '" + ddlMainStatus.SelectedValue + "') and " + attch + " and (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " +
                   " " + probtype + "  and Party_master.Contactperson like'" + txtname.Text + "%' or Party_master.Phoneno ='" + txtname.Text + "' or Party_master.Email ='" + txtname.Text + "'";
        }
        else if (ddlMainStatus.SelectedIndex > 0)
        {
            s = " WareHouseMaster.Name as Wname,  ServiceStatusMaster.StatusName AS Servicestatus, CustomerServiceCallMaster.CustomerServiceCallMasterId,  " +
                " CustomerServiceCallMaster.Entrydate, CustomerServiceCallMaster.ProblemTitle, CustomerServiceCallMaster.ProblemDescription,  " +
                " CustomerServiceCallMaster.ProblemType, CustomerServiceCallMaster.CustomerId, CustomerServiceCallMaster.ServiceStatusId,  " +
                " Party_master.Compname, Party_master.Contactperson, Party_master.Contactperson as comp,ProblemTypeMaster.ProblemName " +
                " FROM         CustomerServiceCallMaster INNER JOIN " +
                " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId" +
                " WHERE      (ServiceStatusMaster.StatusId = '" + ddlMainStatus.SelectedValue + "') and " + attch + " and (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " +
                " " + probtype + "";

            str2 = " select count(CustomerServiceCallMaster.CustomerServiceCallMasterId) as ci " +
                   " FROM         CustomerServiceCallMaster INNER JOIN " +
                   " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                   " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                   " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId" +
                   " WHERE      (ServiceStatusMaster.StatusId = '" + ddlMainStatus.SelectedValue + "') and " + attch + " and (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " +
                   " " + probtype + "";
        }
        else if (txtname.Text != "")
        {
            s = " WareHouseMaster.Name as Wname, ServiceStatusMaster.StatusName AS Servicestatus, CustomerServiceCallMaster.CustomerServiceCallMasterId,  " +
                " CustomerServiceCallMaster.Entrydate, CustomerServiceCallMaster.ProblemTitle, CustomerServiceCallMaster.ProblemDescription,  " +
                " CustomerServiceCallMaster.ProblemType, CustomerServiceCallMaster.CustomerId, CustomerServiceCallMaster.ServiceStatusId,  " +
                " Party_master.Compname, Party_master.Contactperson, Party_master.Contactperson as comp,ProblemTypeMaster.ProblemName " +
                " FROM         CustomerServiceCallMaster INNER JOIN " +
                " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId" +
                " WHERE  (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " + probtype + " " +
                " and " + attch + " and Party_master.Contactperson like'" + txtname.Text + "%' or Party_master.Phoneno ='" + txtname.Text + "' or Party_master.Email ='" + txtname.Text + "' ";

            str2 = " select count(CustomerServiceCallMaster.CustomerServiceCallMasterId) as ci " +
                   " FROM         CustomerServiceCallMaster INNER JOIN " +
                   " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                   " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                   " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId" +
                   " WHERE  (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " + probtype + " " +
                   " and " + attch + " and Party_master.Contactperson like'" + txtname.Text + "%' or Party_master.Phoneno ='" + txtname.Text + "' or Party_master.Email ='" + txtname.Text + "'";
        }
        else
        {
            s = " WareHouseMaster.Name as Wname, ServiceStatusMaster.StatusName AS Servicestatus, CustomerServiceCallMaster.CustomerServiceCallMasterId,  " +
                " CustomerServiceCallMaster.Entrydate, CustomerServiceCallMaster.ProblemTitle, CustomerServiceCallMaster.ProblemDescription,  " +
                " CustomerServiceCallMaster.ProblemType, CustomerServiceCallMaster.CustomerId, CustomerServiceCallMaster.ServiceStatusId,  " +
                " Party_master.Compname, Party_master.Contactperson, Party_master.Contactperson as comp,ProblemTypeMaster.ProblemName " +
                " FROM         CustomerServiceCallMaster INNER JOIN " +
                " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId" +
                " WHERE     (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " + probtype + " " +
                "  and " + attch + " ";

            str2 = " select count(CustomerServiceCallMaster.CustomerServiceCallMasterId) as ci " +
                   " FROM         CustomerServiceCallMaster INNER JOIN " +
                   " ServiceStatusMaster ON CustomerServiceCallMaster.ServiceStatusId = ServiceStatusMaster.StatusId INNER JOIN " +
                   " User_master ON CustomerServiceCallMaster.CustomerId = User_master.UserID INNER JOIN " +
                   " Party_master ON User_master.PartyID = Party_master.PartyID inner join WareHouseMaster on WareHouseMaster.WareHouseId=Party_master.Whid inner join ProblemTypeMaster on ProblemTypeMaster.ProblemTypeId=CustomerServiceCallMaster.ProblemTypeId" +
                   " WHERE     (CustomerServiceCallMaster.Entrydate between '" + Convert.ToDateTime(txtFromDate.Text) + "' and '" + Convert.ToDateTime(txtTodate.Text) + "') " + probtype + " " +
                   "  and " + attch + " ";
        }


        GridServiceCall.VirtualItemCount = GetRowCount(str2);

        string sortExpression = " CustomerServiceCallMaster.CustomerServiceCallMasterId ,WareHouseMaster.Name,CustomerServiceCallMaster.Entrydate,Party_master.Contactperson,CustomerServiceCallMaster.ProblemType,CustomerServiceCallMaster.ProblemTitle,ServiceStatusMaster.StatusName";

        if (Convert.ToInt32(ViewState["count"]) > 0)
        {
            DataTable dt1 = GetDataPage(GridServiceCall.PageIndex, GridServiceCall.PageSize, sortExpression, s);

            GridServiceCall.DataSource = dt1;
            GridServiceCall.DataBind();

            Session["data"] = dt1;
        }
        else
        {
            GridServiceCall.DataSource = null;
            GridServiceCall.DataBind();
        }
    }