|
<%@ Page Language="C#" AutoEventWireup="true" Theme="Griedviewtheme" MasterPageFile="~/Panel/AgentMasterPage.master" CodeFile="SelectedServices.aspx.cs" Inherits="Panel_AgentPanel_SelectedServices" %>
<asp:Content ID="con1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript" src="../../JS/Checkbox.js" language ="javascript"></script>
<asp:Panel ID="Panel1" runat="server" Width="100%">
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td class="commentheader1">
Active Services</td>
<td class="right">
<asp:LinkButton ID="lnkbt_changepwd" runat="server" OnClick="lnkbt_changepwd_Click" Font-Underline="false" >Change Pwd</asp:LinkButton>
<asp:Image ID="Image1" runat="server" Height="10px" ImageUrl="~/Image/seprator.gif" Width="1px" />
<asp:LinkButton ID="lbt_logout" runat="server" OnClick="lbt_logout_Click" Font-Underline="false">Logout</asp:LinkButton></td>
</tr>
<tr>
<td colspan="2" class="right" style="height: 15px">
</td>
</tr>
<tr>
<td colspan="2" class="error">
<asp:Label ID="lb_error" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="space" colspan="2">
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="gd_skills1" Width="730px" runat="server" OnRowCreated="gd_skills1_RowCreated" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chkBxHeader" runat="server" Text="Select All"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkBxSelect" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="fullnameservice" HeaderText="Services" >
<ItemStyle HorizontalAlign="Left" Width="50%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td>
</td>
<td class="space">
</td>
</tr>
<tr>
<td >
<asp:Button ID="bt_ok" runat="server" OnClick="bt_ok_Click" Text="OK" Width="68px" /></td>
<td >
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>
Arvind
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
using System.Text.RegularExpressions;
using System.IO;
using QMS_Component;
using QMS_Transaction;
using System.Diagnostics;
using QMS_MainControl;
public partial class Panel_AgentPanel_SelectedServices : System.Web.UI.Page
{
DataBaseSupport db = new DataBaseSupport();
DataTable dt = new DataTable();
public static bool service_count;
Transaction tr = new Transaction();
EventsLog EL = new EventsLog();
string fname, pageName = "Selected Services Page", Tab = " ", serverlog;
BussinessFunction BF = new BussinessFunction();
LogStatus logStatus = new LogStatus();
int logLevelSet, level;
string uniqueId;
bool writeErrorLog = false;
# region Page loading---------
protected void Page_Load(object sender, EventArgs e)
{
try
{
uniqueId = BF.UniqueId();
logLevelSet = logStatus.logStatusLevel(uniqueId);
level = 2;
Tab = " ==>";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
Tab = " ";
fname = Transaction.file_name;
// update agentloginsession
Logout_Update();
Transaction.val = "";
if (Session["AID"] == null)
{
logout();
Response.Redirect("~/Panel/AgentPanel/sessionexpired.aspx");
}
else
{
lnkbt_changepwd.Attributes.Add("onclick", "window.open ('../agentpanel/changepwd.aspx','popupwindow','width=780,height=350,scrollbars,resizable')");
if (!(Page.IsPostBack))
{
string CounterNo = "";
string aid = Convert.ToString(Session["AID"]);
show_sessioninfo(aid);
string ipAddr = Request.ServerVariables["REMOTE_ADDR"].ToString();
string ip_ctr = "select distinct CounterNo from Counter where IP='" + ipAddr + "' and counterstatus=1"; // Get counter no
dt = db.GetDataTable(ip_ctr);
if (dt.Rows.Count > 0)
{
CounterNo = dt.Rows[0][0].ToString();
}
showServices1(aid, CounterNo);
//showServices2(aid, CounterNo);
}
}
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
# region Logout_Update function
public void Logout_Update()
{
try
{
string ipAddr = "", Counter = "", AID = "", logout = "";
//Get AgentID of the hitter Counter
ipAddr = Request.ServerVariables["REMOTE_ADDR"].ToString();
string ip_ctr = "select distinct CounterNo from Counter where IP='" + ipAddr + "'";
dt = db.GetDataTable(ip_ctr);
if (dt.Rows.Count > 0)
{
Counter = dt.Rows[0][0].ToString();
}
string ip_agent = "select distinct AgentID from agentloginsession where logstatus='1' and CounterNo='" + Counter + "'"; // Get AgentID
dt = db.GetDataTable(ip_agent);
if (dt.Rows.Count > 0)
{
AID = dt.Rows[0][0].ToString();
}
level = 1;
serverlog = "Process:Agent " + AID + " is being logout updated...................";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
//Call logoutagent stored procedure
logout = "updatelogoutagent";
MySqlParameter[] param = new MySqlParameter[1];
param[0] = new MySqlParameter("AID", AID);
int i = db.ExecuteStorPro(logout, param);
if (i > 0)
{
level = 2;
serverlog = "Success:Agent " + AID + " logout updated successfuly.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
}
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
# region Logout function
public void logout()
{
try
{
string ipAddr = "", Counter = "", AID = "", logout = "";
//Get AgentID of the hitter Counter
ipAddr = Request.ServerVariables["REMOTE_ADDR"].ToString();
string ip_ctr = "select distinct CounterNo from Counter where IP='" + ipAddr + "'";
dt = db.GetDataTable(ip_ctr);
if (dt.Rows.Count > 0)
{
Counter = dt.Rows[0][0].ToString();
}
string ip_agent = "select distinct AgentID from agentloginsession where logstatus='1' and CounterNo='" + Counter + "'";
dt = db.GetDataTable(ip_agent);
if (dt.Rows.Count > 0)
{
AID = dt.Rows[0][0].ToString();
}
level = 3;
writeErrorLog = true;
serverlog = "Error:Agent " + AID + " is being logout due to session expiration............";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
string time1 = DateTime.Now.TimeOfDay.ToString();
DateTime l_time = Convert.ToDateTime(time1);
string logouttime = DateTime.Now.ToString();
DateTime lgtime = Convert.ToDateTime(logouttime);
string reason_txt = "Session expired";
//Call logoutagent stored procedure
logout = "logoutagent";
MySqlParameter[] param = new MySqlParameter[3];
//param[0] = new MySqlParameter("Counter", Counter);
param[0] = new MySqlParameter("AID", AID);
////param[1] = new MySqlParameter("l_time", l_time);
param[1] = new MySqlParameter("l_time", lgtime);
param[2] = new MySqlParameter("Reason", reason_txt);
int i = db.ExecuteStorPro(logout, param);
if (i > 0)
{
string del_xtragent = "delete from extraagentservice where AgentID='" + AID + "'";
int del = db.ExecuteMySql(del_xtragent);
string del_temptab = "delete from temptab where AgentID='" + AID + "'";
int del_1 = db.ExecuteMySql(del_temptab);
////string agentlogout = "update agentloginsession set SessionTime= timediff(LogoutTime,LoginTime),safestatus='u',DataSendFlag=0 where (AgentID='" + AID + "')";
string agentlogout = "update agentloginsession set SessionTime= timediff(LogoutDateTime,LoginDateTime),safestatus='u',DataSendFlag=0 where (AgentID='" + AID + "')";
int j = db.ExecuteMySql(agentlogout);
level = 2;
serverlog = "Success:Agent " + AID + " loggedout successfuly due to session expiration.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
}
else
{
level = 3;
writeErrorLog = true;
serverlog = "Error:Unable to logout agent " + AID;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
# region OK Button click
protected void bt_ok_Click(object sender, EventArgs e)
{
try
{
Session["BuzzCount"] = 0;
Session["BuzzTicket"] = 0;
Session["Flag"] = false;
Session["AssignTime"] = "0";
Session["Ticket"] = "0";
Session["StopAutoTicket"] = "0";
//Session["IsPostbackTrue"] = "True";
string aid = Convert.ToString(Session["AID"]);
level = 1;
serverlog = "Process:Agent " + aid + " pressed OK button.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
int cnfm;
save_services(aid, out cnfm);
if (cnfm == 1)
{
Response.Redirect("~/Panel/AgentPanel/NewAssignpage.aspx");
}
else
{
level = 3;
writeErrorLog = true;
serverlog = "Error:Agent " + aid + " didn't choose atleast one service.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
lb_error.Visible = true;
lb_error.Text = "*Please choose atleast one service.";
}
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
# region Save_Services function
public void save_services(string aid, out int cnfm)
{
try
{
level = 1;
serverlog = "Process:Saving of services for agent " + aid + " is being processed.................";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
//save data of first grid
string rw = "", ser = "", ipAddr = "", Counter = "";
int y = 0;
ipAddr = Request.ServerVariables["REMOTE_ADDR"].ToString();
string ip_ctr = "select distinct CounterNo from Counter where counterstatus=1 and IP='" + ipAddr + "'";
dt = db.GetDataTable(ip_ctr);
if (dt.Rows.Count > 0)
{
Counter = dt.Rows[0][0].ToString();
string str_del = "delete from extraagentservice where agentid='" + aid + "'";
int d = db.ExecuteMySql(str_del);
for (int i = 0; i < gd_skills1.Rows.Count; i++)
{
GridViewRow row = gd_skills1.Rows[i];
bool ischecked = ((CheckBox)row.FindControl("chkBxSelect")).Checked;
if (ischecked)
{
rw = gd_skills1.Rows[i].Cells[1].Text;
////string convertSer = "select service from services where sStatus=1 and fullnameservice='" + rw + "'";
string convertSer = "select serviceno from services where sStatus=1 and fullnameservice='" + rw + "'";
dt = db.GetDataTable(convertSer);
if (dt.Rows.Count > 0)
{
ser = dt.Rows[0][0].ToString();
}
string strrefid = "select refid from clientinfo";
string refid = "";
DataTable dtt = new DataTable();
dtt = db.GetDataTable(strrefid);
if (dtt.Rows.Count > 0)
{
refid = dtt.Rows[0]["refid"].ToString();
}
string insert_exagser = "Insertextraagentservice1";
MySqlParameter[] param = new MySqlParameter[4];
param[0] = new MySqlParameter("refid", refid);
param[1] = new MySqlParameter("AID", aid);
param[2] = new MySqlParameter("TOS", ser);
param[3] = new MySqlParameter("Counter", Counter);
y = db.ExecuteStorPro(insert_exagser, param);
}
}
if (y == 1)
{
level = 2;
serverlog = "Success:Saving of services for agent " + aid + " done successfuly.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
cnfm = 1;
}
else
{
level = 3;
writeErrorLog = true;
serverlog = "Error:Unable to save services for agent " + aid + ".";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
cnfm = 0;
}
}
else
{
level = 3;
writeErrorLog = true;
serverlog = "Error:Unable to save services for agent " + aid + " due to unable to find counter for this IP.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
cnfm = 0;
}
}
catch (Exception ex)
{
cnfm = 0;
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
#endregion
# region Show Services
public void showServices1(string aid, string Counter)
{
try
{
level = 1;
serverlog = "Process:Services of agent " + aid + " is being showed for grid1............";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
string str_showserv = "select s.fullnameservice from services as s where (sStatus=1 and s.serviceno in (select ag.serviceno from agentservice as ag,counter as c where (ag.agentid='" + aid + "' and c.CounterNo='" + Counter + "' and ag.serviceno=c.serviceno)))";
dt = db.GetDataTable(str_showserv);
if (dt.Rows.Count > 0)
{
level = 2;
serverlog = "Success:Services of agent " + aid + " for grid1 showed successfuly.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
gd_skills1.DataSource = dt;
gd_skills1.DataBind();
CheckBox mychk = (CheckBox)gd_skills1.HeaderRow.FindControl("chkBxHeader");
mychk.Enabled = false;
for (int i = 0; i < gd_skills1.Rows.Count; i++)
{
GridViewRow row = gd_skills1.Rows[i];
((CheckBox)row.FindControl("chkBxSelect")).Checked = true;
((CheckBox)row.FindControl("chkBxSelect")).Enabled = false;
}
}
else
{
level = 3;
writeErrorLog = true;
serverlog = "Unable to show services of agent " + aid + " for grid1.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
# region Show Sessioninformation
public void show_sessioninfo(string aid)
{
try
{
level = 1;
serverlog = "Process:Sessioninfo of agent " + aid + " is being showed...................";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
string ldate = "select date_format( LoginDateTime,'%Y-%m-%d') as LoginDate from agentloginsession where AgentID='" + aid + "' and logstatus=0 order by LoginDateTime desc limit 1";
dt = db.GetDataTable(ldate);
if (dt.Rows.Count > 0)
{
string last_date = dt.Rows[0][0].ToString();
string sh_lastime = "select date_format( LoginDateTime,'%b %d,%Y') as LoginDate,time(LoginDateTime) as LoginTime,date_format( LogoutDateTime,'%b %d,%Y') as LogoutDate,time(LogoutDateTime) as LogoutTime from agentloginsession where AgentID='" + aid + "' and logstatus=0 and date(LoginDateTime)='" + last_date + "' order by LoginDateTime desc limit 1";
dt = db.GetDataTable(sh_lastime);
if (dt.Rows.Count > 0)
{
level = 2;
serverlog = "Success:Sessioninfo of agent " + aid + " showed successfuly.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
string date = dt.Rows[0][0].ToString();
lb_error.Visible = true;
lb_error.Text = "Your last session info: " + dt.Rows[0]["LoginDate"].ToString() + " " + dt.Rows[0]["LoginTime"].ToString() + " to " + dt.Rows[0]["LogoutDate"].ToString() + " " + dt.Rows[0]["LogoutTime"].ToString();
}
else
{
level = 2;
serverlog = "Success:Sessioninfo of agent " + aid + " showed successfuly.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
lb_error.Visible = true;
lb_error.Text = "You are logged in first time";
}
}
else
{
level = 2;
serverlog = "Success:Sessioninfo of agent " + aid + " showed successfuly.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
lb_error.Visible = true;
lb_error.Text = "You are logged in first time";
}
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
protected void lnkbt_changepwd_Click(object sender, EventArgs e)
{
lnkbt_changepwd.Attributes.Add("onclick", "window.open ('../Agentpanel/changepwd.aspx','popupwindow','width=780,height=350,scrollbars,resizable')");
}
# region LOgout Linkbutton click
protected void lbt_logout_Click(object sender, EventArgs e)
{
try
{
string aid = Convert.ToString(Session["AID"]);
level = 1;
serverlog = "Process:Agent " + aid + " pressed Logout button.";
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
/* this session object is use to identify that the
request of logout page is coming from Selected
services page not from assignform page
*/
Transaction.val = "Selected Services";
Response.Redirect("~/Panel/AgentPanel/LogOutClient.aspx");
}
catch (Exception ex)
{
serverlog = "Exception:-" + ex.Message.ToString();
level = 3;
writeErrorLog = true;
EL.GeneralLogEvents(pageName, serverlog, Tab, logLevelSet, level, uniqueId, writeErrorLog);
writeErrorLog = false;
}
}
# endregion
protected void gd_skills1_RowCreated(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowType == DataControlRowType.DataRow))
{
CheckBox chkBxSelect = (CheckBox)e.Row.Cells[1].FindControl("chkBxSelect");
CheckBox chkBxHeader = (CheckBox)this.gd_skills1.HeaderRow.FindControl("chkBxHeader");
chkBxSelect.Attributes["onclick"] = string.Format("javascript:ChildClick(this,'{0}');", chkBxHeader.ClientID);
//Generate Header Checkbox Client Script
chkBxHeader.Attributes["onclick"] = "javascript:HeaderClick(this, " + gd_skills1.ClientID + ");";
}
}
}
arvind
var TotalChkBx;
var Counter=0;
function HeaderClick(CheckBox, chkID)
{
//Get target base & child control.
var TargetBaseControl = document.getElementById(chkID);
var TargetChildControl = "chkBxSelect";
//Get all the control of the type INPUT in the base control.
var Inputs = document.getElementsByTagName("input");
//Checked/Unchecked all the checkBoxes in side the GridView.
for(var n = 0; n < Inputs.length; ++n)
if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0)
Inputs[n].checked = CheckBox.checked;
//Reset Counter
Counter = CheckBox.checked ? TotalChkBx : 0;
}
function ChildClick(CheckBox, HCheckBox)
{
//get target base & child control.
var HeaderCheckBox = document.getElementById(HCheckBox);
//Modifiy Counter;
if(CheckBox.checked && Counter < TotalChkBx)
Counter++;
else if(Counter > 0)
Counter--;
//Change state of the header CheckBox.
if(Counter < TotalChkBx)
HeaderCheckBox.checked = true;
else if(Counter == TotalChkBx)
HeaderCheckBox.checked = false;
}
|
|
|
|