//protected void lbReasonCodes_SelectedIndexChanged(object sender, EventArgs e) //{ // lblSelectedReasonCodes.Text = String.Empty; // List<string> selectedReasonCodesList = new List<string>(); // foreach (ListItem item in lbReasonCodes.Items) // { // if (item.Selected) // { // selectedReasonCodesList.Add(item.Value); // } // } // string strSelectedValues = string.Join(", ", selectedReasonCodesList.ToArray()); // lblSelectedReasonCodes.Text = strSelectedValues; //} protected void Wky_ReasonCode_CheckedChanged(Object sender, EventArgs e) { try { if (rbWkyStdReasonCodes.Checked) { weeklystd(); } if (rbWkyCustReasonCodes.Checked) { lblWkyCustMessage.Visible = true; lbWkyReasonCodes.Enabled = true; DataView dvReasonCode = ATMDB.GetDataView("up_getReasonCode"); lbWkyReasonCodes.DataSource = dvReasonCode.Table.DefaultView; lbWkyReasonCodes.DataBind(); lbWkyReasonCodes.Height = 150; foreach (ListItem item in lbWkyReasonCodes.Items) { if (item.Value == "18" || item.Value == "40" || item.Value == "41" || item.Value == "60" || item.Value == "61") { item.Selected = true; } } } } catch (Exception) { log.WriteEntryFormat("Error while loading weekly reason codes"); } }
protected void gvForms_RowDataBound(object sender, GridViewRowEventArgs e) { SygmaFramework.Log log = new SygmaFramework.Log("C:/Logs/ATMLog.log"); string FormId = ""; try { switch (e.Row.RowType) { case DataControlRowType.Header: UserControls_ChangeChecks cc = (UserControls_ChangeChecks)e.Row.FindControl("ChangeChecks1"); if (cc != null) { gChangeCheckScript = cc.ChangeCheckAllBoxScript; } break; case DataControlRowType.DataRow: DataRowView row = (DataRowView)e.Row.DataItem; FormId = row["FormId"].ToString(); WebCommon.SetRowScript(string.Format("javascript: OpenForm({0});", row["FormId"]), e); CheckBox chkSelected = (CheckBox)e.Row.FindControl("chkSelected"); DropDownList ddDriver = (DropDownList)e.Row.FindControl("ddDriver"); DropDownList ddHelper = (DropDownList)e.Row.FindControl("ddHelper"); if (gChangeCheckScript != null) { chkSelected.Attributes.Add("onClick", gChangeCheckScript); } FilterDrivers(row["SygmacenterNo"].ToString()); if (!Convert.IsDBNull(row["DriverId"])) { long DriverId = Convert.ToInt64(row["DriverId"]); ddDriver.DataSource = dtFileredDriver; ddDriver.DataBind(); //ddDriver.Items.FindByValue(row["DriverId"].ToString()).Selected = true; for (int i = 0; i < dtFileredDriver.Rows.Count; i++) { if (ddDriver.Items[i].Value == row["DriverId"].ToString()) { ddDriver.Items[i].Selected = true; break; } } ddDriver.Items.Insert(0, new ListItem("Choose...", "0")); // Handle Inactive Drivers if (ddDriver.SelectedItem.Text == "Choose...") { string driverName = (string)ATMDB.GetScalar("up_p_getDriversNameForInactive", DriverId); ddDriver.Items.Insert(0, new ListItem("** " + driverName + " **", "999")); ddDriver.ClearSelection(); ddDriver.Items.FindByValue("999").Selected = true; ddDriver.BackColor = System.Drawing.Color.Gray; ddDriver.ToolTip = driverName + " is currently marked as inactive. Please change the driver if needed!"; } } else { ddDriver.Items.Clear(); ddDriver.Items.Add(new ListItem("Choose...", "0")); foreach (DataRow rtd in dtFileredDriver.Rows) { ListItem liRTD = new ListItem(rtd["DriverName"].ToString(), rtd["DriverId"].ToString()); ddDriver.Items.Add(liRTD); } ddHelper.Enabled = false; ddHelper.CssClass = "disabled-drop-down"; } if (!Convert.IsDBNull(row["DriverHelperId"])) { long HelperId = Convert.ToInt64(row["DriverHelperId"]); //int val = Convert.ToInt32(row["DriverHelperId"]); ddHelper.DataSource = dtFileredHelper; ddHelper.DataBind(); for (int i = 0; i < dtFileredHelper.Rows.Count; i++) { if (ddHelper.Items[i].Value == row["DriverHelperId"].ToString()) { ddHelper.Items[i].Selected = true; break; } } ddHelper.Enabled = true; ddHelper.Items.Insert(0, new ListItem("Choose...", "0")); // Handle Inactive Helpers if (ddHelper.SelectedItem.Text == "Choose...") { string helperName = (string)ATMDB.GetScalar("up_p_getDriversNameForInactive", HelperId); ddHelper.Items.Insert(0, new ListItem("** " + helperName + " **", "999")); ddHelper.ClearSelection(); ddHelper.Items.FindByValue("999").Selected = true; ddHelper.BackColor = System.Drawing.Color.Gray; ddHelper.ToolTip = helperName + " is currently marked as inactive. Please change the helper if needed!"; } } else { ddHelper.Items.Clear(); ddHelper.Items.Add(new ListItem("Choose...", "0")); foreach (DataRow rtd in dtFileredHelper.Rows) { ListItem liRTD = new ListItem(rtd["DriverName"].ToString(), rtd["DriverId"].ToString()); ddHelper.Items.Add(liRTD); } //ddHelper.Items.FindByText("Choose...").Selected = true; //ddHelper.Enabled = false; //ddHelper.CssClass = "disabled-drop-down"; } if (ddDriver.Items.Count > 0 && ddHelper.Items.Count > 0) { string DriverSel = ddDriver.SelectedItem.ToString(); if (DriverSel.Equals("Choose...") == false) { if (ddHelper.Items.Contains(ddDriver.SelectedItem)) { ddHelper.Items.Remove(ddDriver.SelectedItem); } } string HelperSel = ddHelper.SelectedItem.ToString(); if (HelperSel.Equals("Choose...") == false) { if (ddDriver.Items.Contains(ddHelper.SelectedItem)) { ddDriver.Items.Remove(ddHelper.SelectedItem); } } } if (Convert.ToBoolean(ATMDB.GetScalar("up_p_isRouteStarted", row["FormId"]))) { ddDriver.Enabled = false; ddHelper.Enabled = false; ddDriver.CssClass = "disabled-drop-down"; ddHelper.CssClass = "disabled-drop-down"; } if (Convert.ToInt16(row["StatusId"]) != 0) { ddDriver.Enabled = false; ddHelper.Enabled = false; ddDriver.CssClass = "disabled-drop-down"; ddHelper.CssClass = "disabled-drop-down"; } if (Convert.ToInt16(row["FormTypeId"]) == 2) { ddDriver.Visible = false; ddHelper.Visible = false; } if (Convert.ToInt16(row["IsDriverDuplicated"]) == 1) { ddDriver.BackColor = System.Drawing.Color.Yellow; ddDriver.ToolTip = "This driver is also assigned to other routes on the same day as driver/helper!!!"; } if (Convert.ToInt16(row["IsHelperDuplicated"]) == 1) { ddHelper.BackColor = System.Drawing.Color.Yellow; ddHelper.ToolTip = "This helper is also assigned to other routes on the same day as driver/helper!!!"; } ddDriver.Attributes.Add("onchange", string.Format("UpdateDriverDetails(this, 1, {0}, {1});", row["FormId"], e.Row.RowIndex)); ddHelper.Attributes.Add("onchange", string.Format("UpdateDriverDetails(this, 2, {0}, {1});", row["FormId"], e.Row.RowIndex)); //On each line item add it's ID to a list to be cached activeFormIDs.Add(FormId); break; case DataControlRowType.Footer: //when you hit the footer you've exhausted the page, so we can cache the list Cache.Insert("CachedPayrollFormList", activeFormIDs, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 60, 0)); break; } } catch (Exception ex) { log.WriteEntryFormat("FormId = {0}", FormId); log.WriteEntryFormat("Exception = {0}", ex.ToString()); } }