Exemple #1
0
        private void SelectFactoryByRegion()
        {
            try {
                lstFactory.SelectedIndex = -1;

                int regionID = 0;
                if (ddlFactoryRegion.SelectedIndex != -1)
                {
                    regionID = Convert.ToInt32(ddlFactoryRegion.SelectedItem.Value);
                }

                if (regionID != 0)
                {
                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                        using (SqlDataReader dr = WSCSecurity.RegionFactoryGetByRegion(conn, regionID)) {
                            while (dr.Read())
                            {
                                string factoryNo = dr.GetInt32(dr.GetOrdinal("fty_factory_no")).ToString();
                                foreach (ListItem li in lstFactory.Items)
                                {
                                    if (li.Value == factoryNo)
                                    {
                                        li.Selected = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException("Security.SelectFactoryByRegion", ex);
                throw (wex);
            }
        }
Exemple #2
0
        private void FillRoles(DropDownList ddl)
        {
            try {
                ddl.Items.Clear();
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCSecurity.SecurityRoleGetAll(conn)) {
                        System.Web.UI.WebControls.ListItem item = new ListItem("All", "0");
                        ddl.Items.Add(item);

                        while (dr.Read())
                        {
                            int roleID = dr.GetInt16(dr.GetOrdinal("sro_role_id"));
                            item = new ListItem(dr.GetString(dr.GetOrdinal("sro_role_name")),
                                                roleID.ToString());

                            ddl.Items.Add(item);
                        }
                    }
                }
                ddl.SelectedIndex = 0;
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException("Security.FillRoles", ex);
                throw (wex);
            }
        }
        protected void btnPrintForm_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnPrintForm_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;
                }

                // Give client the url to open the pdf
                string      filePath      = "";
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + "Field Contracting".Replace(" ", "");

                filePath = WSCReports.rptFieldContracting.ReportPackager(UsrCntSelector.CropYear, "", "", "", UsrCntSelector.FieldID.ToString(), auth.UserID, fileName, logoUrl, pdfTempFolder);

                if (filePath.Length > 0)
                {
                    // convert file system path to virtual path
                    filePath = filePath.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                locPDF.Text = filePath;
            }
            catch (Exception ex) {
                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";

            WSCSecurity auth = Globals.SecurityState;

            if (auth.SecurityGroupName.ToUpper().IndexOf("AG ADMIN") == -1)
            {
                Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                return;
            }

            try {
                int bankID = 0;
                if (txtBankID.Text.Length > 0)
                {
                    bankID = Convert.ToInt32(txtBankID.Text);
                }
                WSCBank.BankSave(ref bankID, txtBankName.Text, txtBankNumber.Text,
                                 txtShortName.Text, txtAddrLine1.Text, txtAddrLine2.Text, txtCity.Text,
                                 Common.UILib.GetDropDownText(ddlState), txtZip.Text, txtContactName.Text, txtPhone.Text, txtFax.Text,
                                 txtEmail.Text, txtOther.Text, chkIsActive.Checked, (Globals.SecurityState).UserName);

                if (bankID > 0)
                {
                    ShowBankDetail(bankID);
                }
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        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 DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((HarvestReportTemplate)Master).ReportName.Replace(" ", "");

                int    cropYear = Convert.ToInt32(((HarvestReportTemplate)Master).CropYear);
                int    memberID = ((HarvestReportTemplate)Master).MemberID;
                int    shid     = ((HarvestReportTemplate)Master).SHID;
                string busName  = ((HarvestReportTemplate)Master).BusName;

                string pdf = WSCReports.rptContractSummary.ReportPackager(cropYear, memberID, shid, busName, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((HarvestReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((HarvestReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #7
0
 private void PaymentDescriptionSave(Label lblPayNum, DropDownList ddlFinished,
                                     DropDownList ddlRequired, TextBox txtTransmittalDate,
                                     TextBox txtPaymentDesc, TextBox txtPaymentDescID)
 {
     try {
         // validate data
         if (txtTransmittalDate.Text.Length > 0)
         {
             if (!Common.CodeLib.IsDate(txtTransmittalDate.Text))
             {
                 WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("If you enter a Transmittal Date for payment number " +
                                                                            lblPayNum.Text + ", it must be a valid date (mm/dd/yyyy).");
                 throw warn;
             }
         }
         WSCSecurity auth = Globals.SecurityState;
         WSCPayment.PaymentDescriptionSave(Int32.Parse(txtPaymentDescID.Text),
                                           Int32.Parse(lblPayNum.Text), _cropYear,
                                           txtPaymentDesc.Text,
                                           (Common.UILib.GetDropDownText(ddlRequired) == "Yes" ? true : false),
                                           (Common.UILib.GetDropDownText(ddlFinished) == "Yes" ? true : false),
                                           txtTransmittalDate.Text, auth.UserName);
     }
     catch (Exception ex) {
         Common.CException wex = new Common.CException("PaymentDescription.PaymentDescriptionSave", ex);
         throw (wex);
     }
 }
Exemple #8
0
        private void GetContractList(int shid, int cropYear)
        {
            try {
                ddlContractNumber.Items.Clear();
                ddlSequence.Items.Clear();
                WSCSecurity auth = Globals.SecurityState;

                ddlContractNumber.Items.Add("");

                List <ListBeetContractIDItem> stateList = WSCReportsExec.GetContractListSecure(MemberID, cropYear, auth.UserID);
                foreach (ListBeetContractIDItem state in stateList)
                {
                    ddlContractNumber.Items.Add(state.ContractNumber);
                }

                if (ddlContractNumber.Items.Count == 1)
                {
                    ContractNumber = 0;
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + ".GetContractList", ex);
                throw (wex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e) {

            const string METHOD_NAME = "DoPrintReady";

            try {

                WSCSecurity auth = Globals.SecurityState;
                string logoUrl = Page.MapPath(WSCReportsExec.GetReportLogo());
                string pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string fileName = auth.UserID + "_" + ((MasterReportTemplate)Master).ReportName.Replace(" ", "");
                string cropYear = ((MasterReportTemplate)Master).CropYear;

                string pdf = WSCReports.rptFieldAgronomy.ReportPackager(Convert.ToInt32(cropYear), _factoryList, _stationList, _contractList, 
                    "", auth.UserID, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0) {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
				Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
				((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #10
0
        protected void btnNew_Click(object sender, EventArgs e)
        {
            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;
                }

                NewContractAlertOn();

                // This process creates a temporary new field, but Does Not clear or reset
                // the sequence list for any current contract.

                int seqMax = UsrCntSelector.SequenceNumberMax;
                UsrCntSelector.ResetField();
                UsrCntSelector.SetSequenceNumber(seqMax, 0);
                ClearFieldDetail();

                //txtOtherLldContracts.Text = "";
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to generate a New Field at this time.");
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((HarvestReportTemplate)Master).ReportName.Replace(" ", "");

                int    cropYear = Convert.ToInt32(((HarvestReportTemplate)Master).CropYear);
                string shid     = ((HarvestReportTemplate)Master).SHID.ToString();

                DateTime activityFromDate = DateTime.MinValue;
                DateTime activityToDate   = DateTime.MinValue;
                bool     isLienInfoWanted = false;

                WSCReports.rptEquityStatement rptEqStmt = new WSCReports.rptEquityStatement();
                string pdf = rptEqStmt.ReportPackager(cropYear, DateTime.Now, shid, false, fileName, logoUrl, pdfTempFolder,
                                                      activityFromDate, activityToDate, isLienInfoWanted);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((HarvestReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((HarvestReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnDelete_Click";

            WSCSecurity auth = Globals.SecurityState;

            if (auth.SecurityGroupName.ToUpper().IndexOf("AG ADMIN") == -1)
            {
                Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                return;
            }

            try {
                int bankID = 0;
                if (txtBankID.Text.Length > 0)
                {
                    bankID = Convert.ToInt32(txtBankID.Text);
                }
                WSCBank.BankDelete(bankID, Globals.SecurityState.UserName);

                ClearBankDetail();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #13
0
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = txtFileName.Text;

                // Get File Name
                if (fileName.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please enter a file name.");
                    throw (warn);
                }

                string pdf = "";

                string cropYear = ((MasterReportTemplate)Master).CropYear;
                pdf = WSCReports.rptBeet1099.ReportPackager(cropYear, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }
                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((MasterReportTemplate)Master).ReportName.Replace(" ", "");
                string      reportDate    = txtCpsReportDate.Text;
                string      cropYear      = ((MasterReportTemplate)Master).CropYear;
                string      shid          = txtCpsSHID.Text;

                if (reportDate == null || reportDate.Length == 0 || !Common.CodeLib.IsDate(reportDate))
                {
                    Common.CWarning warn = new Common.CWarning("You must enter a valid report date, mm/dd/yyyy");
                    throw (warn);
                }

                WSCReports.rptContractPayeeSummary rpt = new WSCReports.rptContractPayeeSummary();
                string pdf = rpt.ReportPackager(Int32.Parse(cropYear), DateTime.Parse(reportDate), shid, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth           = Globals.SecurityState;
                string      logoUrl        = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder  = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName       = auth.UserID + "_" + ((HarvestReportTemplate)Master).ReportName.Replace(" ", "");
                string      contractNumber = Common.UILib.GetListText(lstCdsContract, ",");

                // Check required fields: contract number
                if (String.IsNullOrEmpty(contractNumber))
                {
                    Common.CWarning warn = new Common.CWarning("You must select a Contract.");
                    throw (warn);
                }

                string cropYear = ((HarvestReportTemplate)Master).CropYear;
                string pdf      = WSCReports.rptContractDeliverySummary.ReportPackager(Convert.ToInt32(cropYear), Convert.ToInt32(contractNumber), fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((HarvestReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((HarvestReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #16
0
        protected void btnUserEditSave_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnUserEditSave_Click";

            try {
                int userID = 0;
                if (grdUserResults.SelectedRow == null)
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select a user from the User Search Results");
                    throw (warn);
                }
                else
                {
                    userID = Convert.ToInt32(grdUserResults.SelectedRow.Cells[0].Text);
                }

                // Save User's Region assignments and Role assignments
                bool   isActive = chkUserEditIsActive.Checked;
                string roles    = "";

                foreach (ListItem li in lstUserEditRole.Items)
                {
                    if (li.Selected)
                    {
                        if (roles.Length == 0)
                        {
                            roles = li.Value;
                        }
                        else
                        {
                            roles += "," + li.Value;
                        }
                    }
                }

                string regions = "";
                foreach (ListItem li in lstUserEditRegion.Items)
                {
                    if (li.Selected)
                    {
                        if (regions.Length == 0)
                        {
                            regions = li.Value;
                        }
                        else
                        {
                            regions += "," + li.Value;
                        }
                    }
                }

                WSCSecurity.UserSecuritySave(userID, isActive, roles, regions);
                FillUserSearchGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogoIconOnly());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((MasterReportTemplate)Master).ReportName.Replace(" ", "");
                string      cropYear      = ((MasterReportTemplate)Master).CropYear;

                string fromDateTest = txtFromDate.Text;
                if (fromDateTest.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please enter a From Date.");
                    throw (warn);
                }
                DateTime fromDate;
                try {
                    fromDate = Convert.ToDateTime(fromDateTest);
                }
                catch {
                    Common.CWarning warn = new Common.CWarning("Please enter a valid From Date.");
                    throw (warn);
                }

                string toDateTest = txtToDate.Text;
                if (toDateTest.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please enter a To Date.");
                    throw (warn);
                }
                DateTime toDate;
                try {
                    toDate = Convert.ToDateTime(toDateTest);
                }
                catch {
                    Common.CWarning warn = new Common.CWarning("Please enter a valid To Date.");
                    throw (warn);
                }

                string shid = txtShid.Text;

                string pdf = WSCReports.rptDirectDeliveryStatement.ReportPackager(Convert.ToInt32(cropYear), fromDate, toDate,
                                                                                  shid, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((MasterReportTemplate)Master).ReportName.Replace(" ", "");
                string      cropYear      = ((MasterReportTemplate)Master).CropYear;

                // Minimally you must at least pick a factory
                if (_factoryList.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("You must select at least one Factory");
                    throw (warn);
                }

                // Must enter a valid from date
                string   fromDateTemp = txtFromDate.Text;
                DateTime fromDate;
                if (String.IsNullOrEmpty(fromDateTemp) || !DateTime.TryParse(fromDateTemp, out fromDate))
                {
                    Common.CWarning warn = new Common.CWarning("You must enter a valid From Date.");
                    throw (warn);
                }

                string   toDateTemp = txtToDate.Text;
                DateTime toDate;
                if (String.IsNullOrEmpty(toDateTemp) || !DateTime.TryParse(toDateTemp, out toDate))
                {
                    Common.CWarning warn = new Common.CWarning("You must enter a valid To Date.");
                    throw (warn);
                }

                bool isPosted   = chkPosted.Checked;
                bool isPreview  = chkPreview.Checked;
                bool isHardCopy = chkWebHardCopyOnly.Checked;
                bool isEmail    = chkEmail.Checked;
                bool isFax      = false;        //	chkFax.Checked;

                string pdf = WSCReports.rptDailyGrowerTareDetailMaster.ReportPackager(Convert.ToInt32(cropYear), fromDate, toDate, _factoryList,
                                                                                      _stationList, _contractList, isPosted, isPreview, isHardCopy, isEmail, isFax, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(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);
            }
        }
Exemple #20
0
        protected void btnAddField_Click(object sender, EventArgs e)
        {
            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;
                }

                // Add the field if it has a valid lld_id
                if (UsrCntSelector.LldID == 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must first Save this field before adding it to the Contract.");
                    return;
                }
                if (UsrCntSelector.CntLLDID > 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "This field is already contracted for this season.");
                    return;
                }
                if (!(UsrCntSelector.ContractID > 0))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must first select a contract before adding a field to the contract.");
                    return;
                }

                // okay, add the field to the contract.
                int cntlld_cntlld_id_out = 0;

                WSCField.CntLldAddField(UsrCntSelector.ContractID, UsrCntSelector.LldID, UsrCntSelector.CropYear,
                                        auth.UserName, ref cntlld_cntlld_id_out);

                // Bounce sequence number to max value
                if (cntlld_cntlld_id_out > 0)
                {
                    int newMaxSeq = UsrCntSelector.SequenceNumberMax + 1;
                    UsrCntSelector.SetSequenceNumber(newMaxSeq, newMaxSeq);
                }

                ShowContractFieldDetail();
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to Add this Field to this Contract at this time.");
            }
        }
Exemple #21
0
        private void FillEditArea()
        {
            try {
                int userID = Convert.ToInt32(grdUserResults.SelectedRow.Cells[0].Text);

                // Add User's Roles
                lstUserEditRole.SelectedIndex = -1;
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCSecurity.SecurityGetUserRoles(conn, userID)) {
                        while (dr.Read())
                        {
                            string roleID = dr.GetInt32(dr.GetOrdinal("sro_role_id")).ToString();
                            foreach (ListItem li in lstUserEditRole.Items)
                            {
                                if (li.Value == roleID)
                                {
                                    li.Selected = true;
                                    break;
                                }
                            }
                        }
                    }

                    // Add User's Regions
                    lstUserEditRegion.SelectedIndex = -1;
                    using (SqlDataReader dr = WSCSecurity.SecurityGetUserRegions(conn, userID)) {
                        while (dr.Read())
                        {
                            string regionID = dr.GetInt32(dr.GetOrdinal("rgn_region_id")).ToString();
                            foreach (ListItem li in lstUserEditRegion.Items)
                            {
                                if (li.Value == regionID)
                                {
                                    li.Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                // Check whether user is active
                string isActive = grdUserResults.SelectedRow.Cells[3].Text;
                chkUserEditIsActive.Checked = (isActive == "Y");
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException("Security.FillEditArea", ex);
                throw (wex);
            }
        }
Exemple #22
0
        protected void btnPost_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnPost_Click";

            /*
             *  <?xml version="1.0" standalone="yes" ?>
             *  <NewDataSet>
             *      <Table>
             *          <Contract>10018</Contract>
             *          <Amount>43.22</Amount>
             *          <Deduction>1,2</Deduction>
             *      </Table>
             *  </NewDataSet>
             */
            try {
                string xmlData = "";

                // Retrieve the xml document of deductions: contract, amount, and deduction.
                string selectedPath = lblOrigPath.Text;
                if (selectedPath.StartsWith(FILE_LABEL))
                {
                    selectedPath = selectedPath.Substring(FILE_LABEL.Length);
                }

                string fileName = System.IO.Path.GetFileName(selectedPath);
                string filePath = Server.MapPath(@"~/PDF") + @"\" + fileName;

                string xmlFilePath = filePath.Replace(System.IO.Path.GetExtension(filePath), ".xml");
                using (System.IO.StreamReader reader = new StreamReader(xmlFilePath)) {
                    xmlData = reader.ReadToEnd().Replace("\r\n", "");
                }

                int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));

                // Send this xml document, the crop year, and user name to the database.
                WSCSecurity auth = Globals.SecurityState;
                WSCAdmin.ContractDeductionSave(cropYear, auth.UserName, xmlData);

                // We only get here if everything works.
                lblOrigPath.Visible = true;
                lblOrigPath.Text    = "Successfully Posted Deductions for: " + fileName;
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #23
0
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((MasterReportTemplate)Master).ReportName.Replace(" ", "");
                string      cropYear      = ((MasterReportTemplate)Master).CropYear;

                string   letterDate   = txtLlLetterDate.Text;
                DateTime dtLetterDate = DateTime.Now;
                try {
                    dtLetterDate = Convert.ToDateTime(letterDate);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid Leter Date.");
                    throw(warn);
                }
                string   deadlineDate   = txtLlDeadlineDate.Text;
                DateTime dtDeadlineDate = DateTime.Now;
                try {
                    dtDeadlineDate = Convert.ToDateTime(deadlineDate);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid Deadline Date.");
                    throw(warn);
                }

                string pdf = WSCReports.rptLandownerLetter.ReportPackager(Convert.ToInt32(cropYear), dtLetterDate, dtDeadlineDate,
                                                                          _factoryList, _stationList, _contractList, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #24
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            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;
                }

                // Delete this Field \ Land Description when it has a valid LLD_ID.
                // Otherwise just blow it off and do a little reset.

                int lld_id = UsrCntSelector.LldID;
                if (lld_id > 0)
                {
                    WSCField.LegalLandDescDelete(lld_id);
                }
                else
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must be viewing a field already in the system in order to delete it.");
                    return;
                }

                int seq    = 0;
                int seqMax = 0;
                if (UsrCntSelector.SequenceNumber > 0)
                {
                    seq    = 1;
                    seqMax = UsrCntSelector.SequenceNumberMax - 1;
                }

                ClearFieldDetail();
                UsrCntSelector.InitControl(UsrCntSelector.SHID, UsrCntSelector.CropYear, UsrCntSelector.ContractNumber, seq);
            }
            catch (Exception ex) {
                ShowError(ex, @"Unable to Delete this Land Description \ Field at this time.");
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = txtCcFileName.Text;

                // Check required fields: crop year, start #, stop #, file name.
                string contractNumberStart = txtCcContractNumberStart.Text;
                if (contractNumberStart.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please enter the First Contract Number.");
                    throw (warn);
                }
                string contractNumberStop = txtCcContractNumberStop.Text;
                if (contractNumberStop.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please enter the Last Contract Number.");
                    throw (warn);
                }
                if (fileName.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please enter a file name.");
                    throw (warn);
                }

                string cropYear = ((MasterReportTemplate)Master).CropYear;
                string pdf      = WSCReports.rptContractCards.ReportPackager(cropYear, contractNumberStart, contractNumberStop, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
        protected void btnCYOk_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnCYOk_Click";

            try {
                string pdfFile  = "";
                int    cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); // txtCYFirstCropYear
                string lastcy   = txtLastCropYear.Text;
                if (lastcy == "")
                {
                    lastcy = cropYear.ToString();
                }
                int lastCropYear = Convert.ToInt32(lastcy);     // if we didn't capture the last crop year, let the guy print using from/to cy equal
                                                                // the current crop year.  Then user can print and report this as a bug.

                GridViewRow row = grdTransfers.SelectedRow;
                if (row == null)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before printing, please select a transfer from the Transferee -- Temp Transfer listing.");
                    throw (warn);
                }

                int shareTransferID = Convert.ToInt32(row.Cells[(int)TempTransferCols.colShareTransferID].Text);

                WSCSecurity auth = Globals.SecurityState;
                pdfFile = ConfigurationManager.AppSettings["appControl.rptServer"].ToString() +
                          "?RPTSEL=TEMPTRANSFER" +
                          "&USR="******"&PRMS=" + Common.CodeLib.EncodeString(ConfigurationManager.ConnectionStrings["BeetConn"].ToString()) +
                          "^" + cropYear.ToString() +        // int first crop year: actual crop year.
                          "^" + lastCropYear.ToString() +    // int last crop year
                          "^-1" +                            // int contractID; -1 when no contract
                          "^" + shareTransferID.ToString() + // int shareTransferID
                          "^";                               // string save path

                locPDF.Text = pdfFile.Replace("localhost", System.Environment.MachineName);
                //uplCropYearFinder.Update();

                //CloseAndPrint();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((HarvestReportTemplate)Master).ReportName.Replace(" ", "");

                int    memberID     = ((HarvestReportTemplate)Master).MemberID;
                string cropYear     = ((HarvestReportTemplate)Master).CropYear;
                int    shid         = ((HarvestReportTemplate)Master).SHID;
                string busName      = ((HarvestReportTemplate)Master).BusName;
                string deliveryDate = Common.UILib.GetListText(lstDdsDeliveryDay, ",");

                if (shid == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please select a SHID.");
                    throw (warn);
                }

                if (deliveryDate.Length == 0)
                {
                    Common.CWarning warn = new Common.CWarning("Please select a Delivery Date.");
                    throw (warn);
                }

                string pdf = WSCReports.rptDeliveryByDaySummary.ReportPackager(Convert.ToInt32(cropYear), memberID, shid,
                                                                               busName, deliveryDate, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((HarvestReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((HarvestReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #28
0
        protected void btnFactorySave_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnFactorySave_Click";

            try {
                int regionID = 0;
                if (ddlFactoryRegion.SelectedItem == null)
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select Region from the list.");
                    throw (warn);
                }
                else
                {
                    if (ddlFactoryRegion.SelectedItem.Text.ToUpper() == "ALL COOP")
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please do not associate factories to the region All Coop.");
                        throw (warn);
                    }
                    regionID = Convert.ToInt32(ddlFactoryRegion.SelectedItem.Value);
                }

                string factories = "";
                foreach (ListItem li in lstFactory.Items)
                {
                    if (li.Selected)
                    {
                        if (factories.Length == 0)
                        {
                            factories = li.Value;
                        }
                        else
                        {
                            factories += "," + li.Value;
                        }
                    }
                }

                WSCSecurity.UserSecurityRegionFactorySave(regionID, factories);
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        protected void btnSaveContract_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnSaveContract_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;
                }

                if (UsrCntSelector.FieldID == 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "  You cannot Save unless you are viewing a contracted field.");
                    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;
                }

                WSCField.FieldContractingSave(UsrCntSelector.FieldID,
                                              Common.UILib.GetDropDownText(ddlRotationLength),
                                              Common.UILib.GetDropDownText(ddlPriorCrop), Common.UILib.GetDropDownText(ddlBeetYears),
                                              chkRhizomania.Checked, chkAphanomyces.Checked, chkCurlyTop.Checked,
                                              chkFusarium.Checked, chkRhizoctonia.Checked, chkNematode.Checked,
                                              chkCercospora.Checked, chkRootAphid.Checked, chkPowderyMildew.Checked,
                                              Common.UILib.GetDropDownText(ddlPostAphanomyces), Common.UILib.GetDropDownText(ddlPostCercospora), Common.UILib.GetDropDownText(ddlPostCurlyTop),
                                              Common.UILib.GetDropDownText(ddlPostFusarium), Common.UILib.GetDropDownText(ddlPostNematode), Common.UILib.GetDropDownText(ddlPostPowderyMildew),
                                              Common.UILib.GetDropDownText(ddlPostRhizoctonia), Common.UILib.GetDropDownText(ddlPostRhizomania), Common.UILib.GetDropDownText(ddlPostRootAphid),
                                              chkPostWater.Checked, Common.UILib.GetDropDownText(ddlWaterSource), Common.UILib.GetDropDownText(ddlIrrigation),
                                              Common.UILib.GetDropDownText(ddlLandOwnership), Common.UILib.GetDropDownText(ddlTillage), auth.UserName);

                ShowFieldDetail(UsrCntSelector.CntLLDID);
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
        private void DoPrintReady(object sender, CommandEventArgs e)
        {
            const string METHOD_NAME = "DoPrintReady";

            try {
                WSCSecurity auth          = Globals.SecurityState;
                string      logoUrl       = Page.MapPath(WSCReportsExec.GetReportLogo());
                string      pdfTempFolder = Page.MapPath(WSCReportsExec.GetPDFFolderPath());
                string      fileName      = auth.UserID + "_" + ((MasterReportTemplate)Master).ReportName.Replace(" ", "");
                string      cropYear      = ((MasterReportTemplate)Master).CropYear;

                string statementDate = txtStatementDate.Text.Trim();
                string shid          = txtPsSHID.Text;
                string fromShid      = txtPsFromSHID.Text;
                string toShid        = txtPsToSHID.Text;
                string footerText    = rptParam_Footer.Value;

                string paymentDesc = Common.UILib.GetDropDownText(ddlPsPaymentDesc);
                if (paymentDesc.StartsWith("None"))
                {
                    Common.CWarning warn = new Common.CWarning("Please select a Payment having a Payment Date.");
                    throw (warn);
                }

                int  paymentID    = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlPsPaymentDesc));
                bool isCumulative = chkPsIsPaymentSummaryCumulative.Checked;

                string pdf = WSCReports.rptPaymentSummary.ReportPackager(Convert.ToInt32(cropYear), statementDate, shid, fromShid, toShid,
                                                                         paymentID, isCumulative, footerText, fileName, logoUrl, pdfTempFolder);

                if (pdf.Length > 0)
                {
                    // convert file system path to virtual path
                    pdf = pdf.Replace(Common.AppHelper.AppPath(), Page.ResolveUrl("~")).Replace(@"\", @"/");
                }

                ((MasterReportTemplate)sender).LocPDF = pdf;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }