protected void btnSearch_Click(object sender, EventArgs e) { //Search using entered fields, at least one item needs to be entered if ((txtAccountSearch.Text == "") & (txtAddressSearch.Text == "") & (txtConsumerSearch.Text == "") & (txtStandNo.Text == "")) { //no terms entered, cant search because database is too huge lblError.Text = "Please enter at least one search term"; lblError.Visible = true; } else { //do the search and display in grid for selection DataTable dt = new DataTable(); Classes.IDBHandler db = new Classes.DBHandler(); //int headerID = int.Parse(Request.QueryString["JobCardHeaderID"]); dt = db.SearchForJobCard(txtAccountSearch.Text, txtConsumerSearch.Text, txtAddressSearch.Text, txtStandNo.Text); gvAddingItems.DataSource = dt; gvAddingItems.DataBind(); gvAddingItems.Visible = true; if (dt.Rows.Count == 0) { lblError.Text = "There are no records for your search criteria"; lblError.Visible = true; } } btnAddItems.Visible = true; AddItem.Attributes["style"] = "display: block"; }
protected void gvSearchResults_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { if (Request.QueryString["JobCardHeaderID"] != null) { DataTable dt = new DataTable(); Classes.IDBHandler db = new Classes.DBHandler(); int headerID = int.Parse(Request.QueryString["JobCardHeaderID"]); hidJobCardID.Value = headerID.ToString(); dt = db.GetJobCardDetails(headerID); gvSearchResults.DataSource = dt; } else { if (hidJobCardID.Value != "") { DataTable dt = new DataTable(); Classes.IDBHandler db = new Classes.DBHandler(); int headerID = int.Parse(hidJobCardID.Value); dt = db.GetJobCardDetails(headerID); gvSearchResults.DataSource = dt; } else { DataTable dt = new DataTable(); gvSearchResults.DataSource = dt; } } }
protected void btnSendToRoute_Click(object sender, EventArgs e) { int fullcounter = 0; //move the job card routes into the meter reading routes tables and then redirect to Management console //first we need to check if all the instructions were filled in foreach (GridDataItem row in gvSearchResults.Items) { CheckBox chk = (CheckBox)row["MarkCHK"].Controls[0]; //CheckBox tempbox = (CheckBox)row.FindControl("CheckBox1"); Classes.IDBHandler db = new Classes.DBHandler(); Common.ReadingsDetailDBHandler rddb = new Common.ReadingsDetailDBHandler(); if (chk.Checked) { //string statusdescr = gvSearchResults.SelectedItems[row.RowIndex].OwnerTableView.DataKeyValues[3].ToString(); int jobHeaderID = Convert.ToInt32(row.GetDataKeyValue("JobCardHeaderID").ToString()); //check instructions int counter = 0; counter = rddb.CheckInstructions(jobHeaderID); if (counter == 0) { //all instructions have been inserted. move the routes. Boolean correct = rddb.MoveJobCardsToRoutes(jobHeaderID); //change contractID int ContractID = rddb.GetWorkOrderContract(); Users_UserDetail uud = (Users_UserDetail)Session["userDetails"]; Common.ICommonDBHandler cdb = new Common.CommonDBHandler(); UserContract uclst = cdb.GetUserContractList(uud).Where(x => x.EnableContract == true && x.ClientContract.ContractActive == true && x.ContractID == ContractID).FirstOrDefault(); Common.CommonTasks.UserContractDet ucd = cdb.LoadUserContractDetByUserContractID(uclst.UserContractID); Session["UserContractDet"] = ucd; //Redirect to Management Console Response.Redirect("RouteManagementConsole.aspx"); } else { //there are missing instructions - dont allow. lblError.Text = "Cannot transfer routes, please ensure you have added instructions to each meter."; lblError.Visible = true; } fullcounter++; } } if (fullcounter > 0) { gvSearchResults.Rebind(); } else { lblError.Text = "Please select at least one item to send."; lblError.ForeColor = System.Drawing.Color.Red; lblError.Visible = true; } //Response.Redirect("RouteManagementConsole.aspx"); }
protected void btnAddSameInstruction_Click(object sender, EventArgs e) { string listIDs = ""; int counter = 0; foreach (GridDataItem row in gvSearchResults.Items) { CheckBox chk = (CheckBox)row["MarkCHK"].Controls[0]; //CheckBox tempbox = (CheckBox)row.FindControl("CheckBox1"); Classes.IDBHandler db = new Classes.DBHandler(); Common.ReadingsDetailDBHandler rddb = new Common.ReadingsDetailDBHandler(); if (chk.Checked) { //string statusdescr = gvSearchResults.SelectedItems[row.RowIndex].OwnerTableView.DataKeyValues[3].ToString(); int jobHeaderID = Convert.ToInt32(row.GetDataKeyValue("JobCardHeaderID").ToString()); if (counter == 0) { listIDs = jobHeaderID.ToString(); } else { listIDs = listIDs + "," + jobHeaderID.ToString(); } counter++; } } if (Session["jobIDs"] == null) { Session.Add("jobIDs", listIDs); } else { if (Session["jobIDs"].ToString() != listIDs) { Session["jobIDs"] = listIDs; Session["openPopUp"] = "n"; } else { Session["jobIDs"] = listIDs; Session["openPopUp"] = "y"; } } if (counter > 0)//Session["openPopUp"] = "n"; { if ((Session["openPopUp"] == "n") || (Session["openPopUp"] == null)) { ClientScript.RegisterStartupScript(this.GetType(), "setInstruction", "<script>window.open('SetComment.aspx?all=y&JobCardHeaderID=" + listIDs + "', 'setInstruction', 'toolbar=0,location=0,status=1,menubar=0,scrollbars=1,top=50,left=50,width=550,height=270,resizable=1');</script>"); } } else { lblError.Visible = true; lblError.Text = "Please select at least one route to edit the instructions of."; } }
protected void gvSearchResults_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { DataTable dt = new DataTable(); Classes.IDBHandler db = new Classes.DBHandler(); dt = db.GetJobCardConsoleGrid(ucd.ContractID); gvSearchResults.DataSource = dt; }
protected void Page_Load(object sender, EventArgs e) { Users_UserDetail uud = (Users_UserDetail)Session["userDetails"]; ucd = (Common.CommonTasks.UserContractDet)Session["UserContractDet"]; if (!IsPostBack) { Classes.IDBHandler db = new Classes.DBHandler(); if (Request.QueryString["MeterNo"] != null) { MeterNoRec = Request.QueryString["MeterNo"]; lblMeterNo.Text = MeterNoRec; } } }
protected void btnDeleteRoutes_Click(object sender, EventArgs e) { int fullcounter = 0; //move the job card routes into the meter reading routes tables and then redirect to Management console //first we need to check if all the instructions were filled in foreach (GridDataItem row in gvSearchResults.Items) { CheckBox chk = (CheckBox)row["MarkCHK"].Controls[0]; //CheckBox tempbox = (CheckBox)row.FindControl("CheckBox1"); Classes.IDBHandler db = new Classes.DBHandler(); Common.ReadingsDetailDBHandler rddb = new Common.ReadingsDetailDBHandler(); if (chk.Checked) { //string statusdescr = gvSearchResults.SelectedItems[row.RowIndex].OwnerTableView.DataKeyValues[3].ToString(); int jobHeaderID = Convert.ToInt32(row.GetDataKeyValue("JobCardHeaderID").ToString()); if (rddb.DeleteJobCards(jobHeaderID)) { lblError.Text = "Route(s) successfully deleted."; lblError.ForeColor = System.Drawing.Color.Black; lblError.Visible = true; } else { lblError.Text = "A problem has occured. Please try again."; lblError.ForeColor = System.Drawing.Color.Red; lblError.Visible = true; } fullcounter++; } } if (fullcounter > 0) { gvSearchResults.Rebind(); } else { lblError.Text = "Please select at least one item to delete."; lblError.ForeColor = System.Drawing.Color.Red; lblError.Visible = true; } }
protected void gvAddingItems_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { if (!String.IsNullOrWhiteSpace(txtAccountSearch.Text) || !String.IsNullOrWhiteSpace(txtAddressSearch.Text) || !String.IsNullOrWhiteSpace(txtConsumerSearch.Text) || !String.IsNullOrWhiteSpace(txtStandNo.Text)) { DataTable dt = new DataTable(); Classes.IDBHandler db = new Classes.DBHandler(); dt = db.SearchForJobCard(txtAccountSearch.Text, txtConsumerSearch.Text, txtAddressSearch.Text, txtStandNo.Text); gvAddingItems.DataSource = dt; gvAddingItems.Visible = true; if (dt.Rows.Count == 0) { lblError.Text = "There are no records for your search criteria"; lblError.Visible = true; } } }
protected void btnDelete_Click(object sender, EventArgs e) { int counter = 0; foreach (GridDataItem row in gvSearchResults.Items) { CheckBox chk = (CheckBox)row["MarkCHK"].Controls[0]; Classes.IDBHandler db = new Classes.DBHandler(); if (chk.Checked) { //int JobCardHeaderID = int.Parse(row.GetDataKeyValue("JobCardHeaderID").ToString()); int JobCardDetailsID = Convert.ToInt32(row["JobCardDetailsID"].Text); if (db.deleteJobCardDetails(JobCardDetailsID, uud.UserID)) { lblError.Text = "Item successfully deleted."; lblError.ForeColor = System.Drawing.Color.Black; lblError.Visible = true; } else { lblError.Text = "An error occured while trying to remove the item. Please try again."; lblError.ForeColor = System.Drawing.Color.Red; lblError.Visible = true; } counter++; } } if (counter > 0) { gvSearchResults.Rebind(); } else { lblError.Text = "Please select at least one item to delete."; lblError.ForeColor = System.Drawing.Color.Red; lblError.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { uud = (Users_UserDetail)Session["userDetails"]; ucd = (Common.CommonTasks.UserContractDet)Session["UserContractDet"]; isWebAdmin = uud.IsWebAdmin == true ? "Y" : ""; isClientAdmin = uud.IsClientAdmin == true ? "Y" : ""; isOperator = uud.IsOperator == true ? "Y" : ""; isMetermanClient = ucd.isMetermanClient == true ? "Y" : ""; lblContractName.Text = "<br/>Client: " + ucd.ClientName + " | Contract: " + ucd.ContractName; if (!IsPostBack) { Classes.IDBHandler db = new Classes.DBHandler(); gvSearchResults.AllowPaging = uud.ShowPaging; //Set the current sort field and order ViewState["SearchResultSortDirection"] = "ASC"; ViewState["SearchResultSortExpression"] = "RouteName"; if (Request.QueryString["new"] == null) { string routeName = db.getJobCardRouteName(Convert.ToInt32(Request.QueryString["JobCardHeaderID"]), uud.UserID); if (routeName.Substring(0, 3) == "MAN") { //we can add more items } else { //it came from validations, can't add more items. btnAddOther.Visible = false; btnDelete.Visible = false; } } else { if (Request.QueryString["JobCardHeaderID"] == null) { btnSame.Visible = false; } else { string RouteName = db.getJobCardRouteName(Convert.ToInt32(Request.QueryString["JobCardHeaderID"]), uud.UserID).ToString(); btnSame.Visible = true; if (Request.QueryString["create"] == null) { lblError.Text = "Route " + RouteName + " was updated successfully."; } else { lblError.Text = "Route " + RouteName + " was created successfully."; } lblError.ForeColor = System.Drawing.Color.Black; lblError.Visible = true; } } if (Session["alreadyRun"] == null) { Session.Add("alreadyRun", "n"); } else { Session["alreadyRun"] = "n"; } } if ((Session["alreadyRun"] == "y")) { //gvSearchResults.DataSource = null; Session["alreadyRun"] = "n"; //gvSearchResults.Rebind(); Response.Redirect(Request.Url.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { uud = (Users_UserDetail)Session["userDetails"]; ucd = (Common.CommonTasks.UserContractDet)Session["UserContractDet"]; isWebAdmin = uud.IsWebAdmin == true ? "Y" : ""; isClientAdmin = uud.IsClientAdmin == true ? "Y" : ""; isOperator = uud.IsOperator == true ? "Y" : ""; isMetermanClient = ucd.isMetermanClient == true ? "Y" : ""; lblContractName.Text = "<br/>Client: " + ucd.ClientName + " | Contract: " + ucd.ContractName; if (!IsPostBack) { Classes.IDBHandler db = new Classes.DBHandler(); //List<WebNM_GetUniqueRouteByContractID_proc_Result> routelst = db.GetUniqueRoutesByContractID(ucd, false).ToList(); //Common.CommonTasks.Binddropdownlist<WebNM_GetUniqueRouteByContractID_proc_Result>(ddlRoute, routelst, "RouteName", "RouteName", "--Select--"); //List<WebNM_RouteReadingStatus> statuslst = db.GetAllActiveRouteStatus().ToList(); //Common.CommonTasks.Binddropdownlist<WebNM_RouteReadingStatus>(ddlReadingStatus, statuslst, "Description", "RouteReadingStatusID", "--Select--"); //ddlReadingStatus.SelectedIndex = 1; //List<WebNM_GetMeterReaderDetailsByContract_proc_Result> readerlst = db.GetReaderDetailsByContractID(int.Parse(ucd.ContractID.ToString())).ToList(); gvSearchResults.AllowPaging = uud.ShowPaging; loadGrid("RouteName ASC"); //gvSearchResults.Columns[13].Visible = false; //Set the current sort field and order ViewState["SearchResultSortDirection"] = "ASC"; ViewState["SearchResultSortExpression"] = "RouteName"; //if (ucd.isMetermanClient || (uud.IsWebAdmin != true && uud.IsClientAdmin != true && uud.IsOperator != true)) //{ // //btDelete.Visible = false; //commented out 28062013 by Jerome Dimairho as requested by Rudolf Earle // btArchiveComplete.Visible = false; //} if (Session["alreadyRun"] == null) { Session.Add("alreadyRun", "n"); } else { Session["alreadyRun"] = "n"; } if (Session["openPopUp"] == null) { Session.Add("openPopUp", "n"); } else { Session["openPopUp"] = "n"; } } if ((Session["alreadyRun"] == "y")) { gvSearchResults.AllowPaging = uud.ShowPaging; loadGrid("RouteName ASC"); Session["alreadyRun"] = "n"; } }