private void FindAddress(string shid) { const string METHOD_NAME = "FindAddress"; try { ResetShareholder(); if (shid.Length > 0) { int memberID = 0, addressID = 0; string phone = "", email = "", fax = "", busName = ""; WSCMember.GetInfo(shid, ref memberID, ref addressID, ref busName, ref phone, ref email, ref fax); MySHID = shid; MyMemberID = memberID.ToString(); lblBusName.Text = busName; FindMemberOverPlant(memberID); } } catch (Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
public void ResetMemberInfo(string shid) { int memberID = 0, addressID = 0; string phone = "", fax = "", emailAddress = ""; try { WSCMember.GetInfo(shid, ref memberID, ref addressID, ref _busName, ref phone, ref emailAddress, ref fax); } catch (System.Exception ex) { throw (ex); } if (memberID > 0) { MemberID = memberID; AddressID = addressID; SHID = Convert.ToInt32(shid); EmailAddress = emailAddress; } else { ResetShareholder(); } }
protected void btnSaveAddress_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnSaveAddress_Click"; try { if (UsrCntSelector.IsChangedSHID) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button. Please press Find."); return; } WSCSecurity auth = Globals.SecurityState; if (!UsrCntSelector.IsOwner) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information"); return; } string email = txtEmail.Text; if (!Common.CodeLib.ValidateEmail(email)) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter a valid email address."); return; } WSCMember.UpdateAddress(UsrCntSelector.MemberID, email, UsrCntSelector.FaxNumber, Globals.SecurityState.UserName); UsrCntSelector.EmailAddress = email; } catch (Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
private void SetupNorthSouth() { try { if (MemberID > 0) { string northSouth = WSCMember.GetFactoryNorthSouth(AddressID); FillDecisionQueries(ddlQuery1, northSouth); FillDecisionQueries(ddlQuery2, northSouth); FillDecisionQueries(ddlQuery3, northSouth); FillDecisionQueries(ddlQuery4, northSouth); FillDecisionQueries(ddlQuery5, northSouth); FillDecisionQueries(ddlQuery6, northSouth); FillResList(ddlRes1); FillResList(ddlRes2); FillResList(ddlRes3); FillResList(ddlRes4); FillResList(ddlRes5); FillResList(ddlRes6); btnSearch.Enabled = true; if (northSouth == "NORTH") { divNurseryNorth.Attributes.Add("class", "BlockNav"); divNurserySouth.Attributes.Add("class", "DisplayOff"); } else { divNurseryNorth.Attributes.Add("class", "DisplayOff"); divNurserySouth.Attributes.Add("class", "BlockNav"); } txtNorthSouth.Text = northSouth; } else { // disable all north/south controls. ddlQuery1.Enabled = false; ddlQuery2.Enabled = false; ddlQuery3.Enabled = false; ddlQuery4.Enabled = false; ddlQuery5.Enabled = false; ddlQuery6.Enabled = false; ddlRes1.Enabled = false; ddlRes2.Enabled = false; ddlRes3.Enabled = false; ddlRes4.Enabled = false; ddlRes5.Enabled = false; ddlRes6.Enabled = false; btnSearch.Enabled = false; txtNorthSouth.Text = ""; } } catch (System.Exception ex) { throw (ex); } }
protected void btnChange_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnChange_Click"; try { // Did page load already throw an error? if (((HtmlGenericControl)Master.FindControl("divWarning")).InnerHtml.Length > 0) { return; } if (SHID.ToString() != txtSHID.Text) { Common.CWarning wex = new Common.CWarning("Please press the Find button to ensure you're editing the correct Shareholder before trying to Save."); throw (wex); } if (SHID == 0) { Common.CWarning wex = new Common.CWarning("Please enter a SHID and press the Find button."); throw (wex); } WSCSecurity auth = Globals.SecurityState; if (auth.AuthorizeShid(SHID, CropYear) < WSCSecurity.ShsPermission.shsReadWrite) { Common.CWarning warn = new Common.CWarning("Sorry, you are not authorized to update this information"); throw (warn); } if (EmailAddress.Length == 0) { Common.CWarning warn = new Common.CWarning("Please create an email address for this member."); throw (warn); } string warnMsg = null; WSCMember.ResetPassword(SHID.ToString(), EmailAddress, ref warnMsg); if (warnMsg == null) { Common.AppHelper.ShowConfirmation((HtmlGenericControl)Master.FindControl("divWarning"), "Password has been reset and sent to you via email."); } else { Common.CWarning warn = new Common.CWarning(warnMsg); throw (warn); } } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
private void FindAddress(string shid) { const string METHOD_NAME = "FindAddress"; if (shid == null || shid.Length == 0) { ResetShareholder(); Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter a SHID."); return; } try { ResetMemberInfo(shid); txtSHID.Text = SHID.ToString(); lblBusName.Text = _busName; txtEmail.Text = _emailAddress; txtFax.Text = _fax; string sendRptOption = null; if (MemberID > 0) { WSCMember.GetSendRptOption(MemberID, ref sendRptOption); } SetSendRptOption(sendRptOption); if (txtEmail.Text.Length == 0) { lblEmail.CssClass = "WarningOn"; lblEmail.Text = "* Missing *"; } else { lblEmail.CssClass = "WarningOff"; lblEmail.Text = ""; } if (txtFax.Text.Length == 0) { lblFax.CssClass = "WarningOn"; lblFax.Text = "* Missing *"; } else { lblFax.CssClass = "WarningOff"; lblFax.Text = ""; } } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
private void GetShareholder(int shid, int cropYear) { try { int memberID = 0, addressID = 0; string phone = "", email = "", fax = ""; WSCMember.GetInfo(shid.ToString(), ref memberID, ref addressID, ref _busName, ref phone, ref email, ref fax); SHID = shid; CropYear = cropYear; MemberID = memberID; AddressID = addressID; } catch (Exception ex) { Common.CException wex = new Common.CException("UserContractSelector.GetShareholder", ex); throw (wex); } }
private void ResetMemberInfo(string shid) { const string METHOD_NAME = "ResetMemberInfo"; int memberID = 0, addressID = 0; string busName = "", phone = "", email = "", fax = ""; try { WSCMember.GetInfo(shid, ref memberID, ref addressID, ref busName, ref phone, ref email, ref fax); ResetShareholder(); if (memberID > 0) { MemberID = memberID; AddressID = addressID; SHID = Convert.ToInt32(shid); BusName = busName; } } catch (Exception ex) { Common.CException wex = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
private void GetShareholder(int shid, int cropYear) { try { int memberID = 0, addressID = 0; string busName = "", phone = "", email = "", fax = ""; WSCMember.GetInfo(shid.ToString(), ref memberID, ref addressID, ref busName, ref phone, ref email, ref fax); SHID = shid; IsChangedSHID = false; AddressID = addressID; MemberID = memberID; if (lblBusName.Text.Length == 0) { lblBusName.Text = busName; } EmailAddress = email; FaxNumber = fax; } catch (Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + ".GetShareholder", ex); throw (wex); } }
protected void Page_Load(object sender, EventArgs e) { const string METHOD_NAME = "Page_Load"; try { Common.AppHelper.HideWarning((HtmlGenericControl)Master.FindControl("divWarning")); Common.AppHelper.HideWarning(lblEmail); Common.AppHelper.HideWarning(lblFax); _shs = Globals.ShsData; if (Globals.IsUserPermissionReadOnly((RolePrincipal)User)) { btnSave.Enabled = false; } if (!Page.IsPostBack) { FillCropYear(); if (_shs.SHID != 0) { FindAddress(_shs.SHID.ToString()); if (txtEmail.Text.Length == 0) { lblEmail.CssClass = "WarningOn"; lblEmail.Text = "* Missing *"; } else { lblEmail.CssClass = "WarningOff"; lblEmail.Text = ""; } if (txtFax.Text.Length == 0) { lblFax.CssClass = "WarningOn"; lblFax.Text = "* Missing *"; } else { lblFax.CssClass = "WarningOff"; lblFax.Text = ""; } string sendRptOption = null; WSCMember.GetSendRptOption(MemberID, ref sendRptOption); SetSendRptOption(sendRptOption); } else { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter a SHID and press the Find button."); } } else { CropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); } } catch (System.Exception ex) { ResetShareholder(); Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
protected void btnSave_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnSave_Click"; try { int currentCropYear = Convert.ToInt32(WSCField.GetCropYears()[0].ToString()); if (currentCropYear != CropYear) { Common.CWarning wex = new Common.CWarning("Sorry, you cannot update information for a prior crop year."); throw (wex); } if (!Common.CodeLib.IsValidSHID(txtSHID.Text)) { Common.CWarning wex = new Common.CWarning("Please enter a valid SHID."); throw (wex); } if (SHID.ToString() != txtSHID.Text) { Common.CWarning wex = new Common.CWarning("Please press the Find button to ensure you're editing the correct Shareholder before trying to Save."); throw (wex); } if (SHID == 0) { Common.CWarning wex = new Common.CWarning("Please enter a SHID and press the Find button."); throw (wex); } WSCSecurity auth = Globals.SecurityState; if (auth.AuthorizeShid(SHID, CropYear) < WSCSecurity.ShsPermission.shsReadWrite) { Common.CWarning wex = new Common.CWarning("Sorry, you are not authorized to update this information"); throw (wex); } // Validate Email or fax when needed. string sendRptOption = GetSendRptOption(); if (txtEmail.Text.Length > 0 || sendRptOption == SEND_RPT_OPT_EMAIL) { if (!Common.CodeLib.ValidateEmail(txtEmail.Text)) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter the information in the correct format"); Common.AppHelper.ShowWarning(lblEmail, "Required to receive reports by email."); return; } } if (txtFax.Text.Length > 0 || sendRptOption == SEND_RPT_OPT_FAX) { if (!Common.CodeLib.ValidateFax(txtFax.Text)) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter the information in the correct format"); Common.AppHelper.ShowWarning(lblFax, "Required to receive reports by fax."); return; } } try { WSCMember.UpdateSendRptOption(MemberID, sendRptOption); Common.AppHelper.ShowConfirmation((HtmlGenericControl)Master.FindControl("divWarning"), "Your changes have been successfully updated!"); } catch (System.Exception ex) { if (Common.AppHelper.IsDebugBuild()) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), ex); } else { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Unable to save your changes at this time.", ex); Common.AppHelper.LogException(ex, HttpContext.Current); } return; } try { WSCMember.UpdateAddress(MemberID, txtEmail.Text, txtFax.Text, Globals.SecurityState.UserName); Common.AppHelper.ShowConfirmation((HtmlGenericControl)Master.FindControl("divWarning"), "Your changes have been successfully updated!"); } catch (System.Exception ex) { if (Common.AppHelper.IsDebugBuild()) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), ex); } else { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Unable to save your changes at this time.", ex); Common.AppHelper.LogException(ex, HttpContext.Current); } } if (((HtmlGenericControl)Master.FindControl("divWarning")).InnerHtml.Length == 0) { Common.AppHelper.ShowConfirmation((HtmlGenericControl)Master.FindControl("divWarning"), "Your information has been updated!"); } } catch (Exception ex) { ResetShareholder(); Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
protected void btnSendEmail_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnSendEmail_Click"; string shidList = txtSHID.Text; string fromEmail = txtFromEmail.Text; string subject = txtSubject.Text; string message = txtMessage.Text; bool SubYesActYes = chkSubYesActYes.Checked; bool SubYesActNo = chkSubYesActNo.Checked; bool SubNo = chkSubNo.Checked; string pathAttach = ""; try { int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); for (int i = 0; i < lstAttach.Items.Count; i++) { if (i > 0) { ListItem li = lstAttach.Items[i]; if (li.Selected) { if (pathAttach.Length > 0) { pathAttach += ";" + Server.MapPath(Page.ResolveUrl("~/ZHost/SendAttachments")) + @"\" + li.Text; } else { pathAttach += Server.MapPath(Page.ResolveUrl("~/ZHost/SendAttachments")) + @"\" + li.Text; } } } } if (lstPendingEmail.Items.Count == 0) { // check that all required fields are passed. if (!SubYesActYes && !SubYesActNo && !SubNo) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please check at lease one of the checkboxes: 'Is Shareholder and Is Active' or 'Is Shareholder, but Not Active' or 'Not a Shareholder'."); throw (warn); } if (pathAttach.Length == 0) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select an attachement from the list."); throw (warn); } if (txtFromEmail.Text.Length == 0) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a From Email Address."); throw (warn); } if (!Common.CodeLib.ValidateEmail(txtFromEmail.Text)) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid From Email Address."); throw (warn); } if (txtSubject.Text.Length == 0) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Subject line for the email."); throw (warn); } if (txtMessage.Text.Length == 0) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Message for the body of the email."); throw (warn); } bool isInternalOnly = (chkInternal.Checked); bool isExternalOnly = (chkExternal.Checked); if (isInternalOnly && isExternalOnly) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You cannot check both 'Only Internal Email' and 'Only External Emal'. Select one or select neither of these options."); throw (warn); } //============================================ // Get list of email addresses //============================================ using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) { using (SqlDataReader dr = WSCMember.GetEmailByShid(conn, shidList, cropYear, SubYesActYes, SubYesActNo, SubNo, isInternalOnly, isExternalOnly)) { while (dr.Read()) { lstPendingEmail.Items.Add(new ListItem(dr.GetString(dr.GetOrdinal("email")), dr.GetInt32(dr.GetOrdinal("memberNumber")).ToString())); } } } hideGoodEmail.Value = ""; hideBadEmail.Value = ""; } //======================================================================================== // Given a list of emails to send, send it; otherwise warn user about zero records. //======================================================================================== if (lstPendingEmail.Items.Count != 0) { DoSendFileWithAttach(fromEmail, subject, message, pathAttach); } else { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your selected criteria, no emails have been sent."); throw (warn); } // Update the batch progress if (lstPendingEmail.Items.Count != 0) { // ========================================================= // Send page back to client and we'll do it again. // ========================================================= Common.AppHelper.ShowConfirmation((HtmlGenericControl)Master.FindControl("divWarning"), "Working (Do not click or press anything)... " + lstPendingEmail.Items.Count.ToString("#,###") + " emails still to send."); } else { SendSummaryEmail(subject, fromEmail, pathAttach); } // Flag for client: Normal process if (lstPendingEmail.Items.Count > 0) { txtContinueBatch.Value = "yes"; } else { txtContinueBatch.Value = ""; } } catch (Exception ex) { // Flag for client: error, process interrupted. txtContinueBatch.Value = ""; Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); if (Common.AppHelper.IsDebugBuild()) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), wex); } else { // Clear out any status/progress message in this case. ((HtmlGenericControl)Master.FindControl("divWarning")).InnerHtml = ""; string userMsg = "Unable to Send Email at this time."; if (_isErrorDuringSummary) { userMsg = "You emailing batch completed, but there was an error when trying to send you a summary.\n" + "These SHID's failed, probably bad email address on file: " + hideBadEmail.Value + " \n\n" + "These SHID's were emailed: " + hideGoodEmail.Value; } else { System.Text.StringBuilder sbTodo = new System.Text.StringBuilder(""); string remains = ""; if (lstPendingEmail.Items.Count > 0) { foreach (ListItem itm in lstPendingEmail.Items) { sbTodo.Append(itm.Value); sbTodo.Append(","); } sbTodo.Length = sbTodo.Length - 1; remains = sbTodo.ToString(); } // Otherwise, we're blowing up somewhere during a batch process. One or more emails remain to be sent. userMsg = "An error interrupted your batch email process. Contact your Network Administrator.\n " + "Copy the detail in this error message for your Network Administrator. \n" + "These SHIDs failed: " + (hideBadEmail.Value.Length == 0? "None": hideBadEmail.Value) + "\n\n" + "These SHIDs were emailed: " + (hideGoodEmail.Value.Length == 0? "None": hideGoodEmail.Value) + "\n\n" + "These SHIDs remain: " + (remains.Length == 0 ? "None" : remains); } Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), userMsg, wex); Common.AppHelper.LogException(wex, HttpContext.Current); } } }
protected void btnSave_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnSave_Click"; string email = ""; string fax = ""; try { if (!Common.CodeLib.IsValidSHID(txtSHID.Text)) { Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid SHID"); throw (warn); } if (SHID.ToString() != txtSHID.Text) { Common.CWarning wex = new Common.CWarning("Please press the Find button to ensure you're editing the correct Shareholder before trying to Save."); throw (wex); } if (SHID == 0) { Common.CWarning wex = new Common.CWarning("Please enter a SHID and press the Find button."); throw (wex); } WSCSecurity auth = Globals.SecurityState; if (auth.AuthorizeShid(SHID, CropYear) < WSCSecurity.ShsPermission.shsReadWrite) { Common.CWarning wex = new Common.CWarning("Sorry, you are not authorized to update this information"); throw (wex); } string userName = auth.UserName; email = txtEmail.Text; fax = txtFax.Text; if (email.Length > 0 && !Common.CodeLib.ValidateEmail(email)) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter the information in the correct format"); Common.AppHelper.ShowWarning(lblEmail, "Required to receive reports by email."); return; } if (fax.Length > 0 && !Common.CodeLib.ValidateFax(fax)) { Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter the information in the correct format"); Common.AppHelper.ShowWarning(lblFax, "Required to receive reports by fax."); return; } // Update the email address or fax number when necessary. try { WSCMember.UpdateAddress(MemberID, email, fax, userName); Common.AppHelper.ShowConfirmation((HtmlGenericControl)Master.FindControl("divWarning"), "Your changes have been successfully updated!"); } catch (System.Exception ex) { ResetShareholder(); throw(ex); } } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }