private void FillRowWidth()
        {
            const string METHOD_NAME = "FillRowWidth";

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

                grdResults.DataSource = null;
                grdResults.DataBind();

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCAdmin.PlantPopulationGetByYear(conn, cropYear)) {
                        grdResults.SelectedIndex = -1;
                        grdResults.DataSource    = dr;
                        grdResults.DataBind();
                    }
                }

                if (grdResults.Rows.Count > 0)
                {
                    grdResults.SelectedIndex = 0;
                }
                else
                {
                    grdResults.SelectedIndex = -1;
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Example #2
0
        private void FillForm()
        {
            const string METHOD_NAME = "FillForm";

            try {
                ClearForm();

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

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCAdmin.PassthroughAllGetByYear(conn, cropYear)) {
                        if (dr.Read())
                        {
                            int iFiscalYear   = dr.GetOrdinal("pssaFiscalYearEndDate");
                            int iPercentApply = dr.GetOrdinal("pssaPercentageToApply");
                            int iRatePerTon   = dr.GetOrdinal("pssaRatePerTon");
                            int iReportDate   = dr.GetOrdinal("pssaReportDate");
                            int iTaxYear      = dr.GetOrdinal("pssaTaxYear");

                            // Copy values into form
                            txtFiscalYearEndDate.Text = dr.GetString(iFiscalYear);
                            txtPercentageToApply.Text = dr.GetDecimal(iPercentApply).ToString("N3");
                            txtRatePerTon.Text        = dr.GetDecimal(iRatePerTon).ToString("N6");
                            txtReportDate.Text        = dr.GetString(iReportDate);
                            Common.UILib.SelectDropDown(ddlTaxYear, dr.GetInt32(iTaxYear).ToString());
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Example #3
0
        private void FillLookupTypes()
        {
            const string METHOD_NAME = "FillLookupTypes";

            try {
                ddlType.Items.Clear();
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCAdmin.LookupGetTypesAll(conn)) {
                        while (dr.Read())
                        {
                            ddlType.Items.Add(dr.GetString(dr.GetOrdinal("lkp_lookup_type")));
                        }
                    }
                }

                if (ddlType.SelectedIndex == -1)
                {
                    ddlType.SelectedIndex = 0;
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Example #4
0
        private void SaveLookup()
        {
            const string METHOD_NAME = "SaveLookup";

            string oldDescription = "";
            string newDescription = txtDescription.Text;
            bool   fixOldValues   = false;

            try {
                if (txtDescription.Text.Length == 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter Description text.");
                }

                if (_isNew != "NEW")
                {
                    // Update Description
                    string   itemData = ddlDescription.SelectedItem.Value;
                    string[] vals     = itemData.Split(new char[] { '^' });
                    oldDescription = vals[1];
                    fixOldValues   = (_action == "UPDATE");
                }

                WSCAdmin.LookupSave(ddlType.SelectedValue, chkIsActive.Checked,
                                    oldDescription, newDescription, fixOldValues);
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Example #5
0
        private void DeleteLookup()
        {
            const string METHOD_NAME = "DeleteLookup";

            try {
                string type        = ddlType.SelectedValue;
                string description = ddlDescription.SelectedValue.Substring(1);

                WSCAdmin.LookupDelete(type, description);
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Example #6
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);
            }
        }
 private void FillDomainData()
 {
     try {
         ddlState.Items.Clear();
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
             using (SqlDataReader dr = WSCAdmin.StateGetAll(conn)) {
                 ddlState.Items.Add("");
                 while (dr.Read())
                 {
                     ddlState.Items.Add(dr.GetString(dr.GetOrdinal("ste_abbr")));
                 }
             }
         }
     }
     catch (Exception ex) {
         Common.CException wex = new Common.CException(MOD_NAME + "FillDomainData", ex);
         throw (wex);
     }
 }
        private void SavePlantPopulation()
        {
            const string METHOD_NAME = "SavePlantPopulation";

            try {
                bool isNew = false;

                if (grdResults.Rows.Count == 0)
                {
                    isNew = true;
                }
                else
                {
                    isNew = (grdResults.SelectedIndex == -1);
                }

                int plantPopulationID = 0;
                if (!isNew)
                {
                    // Updates require a row width selection
                    if (grdResults.SelectedRow != null)
                    {
                        plantPopulationID = Convert.ToInt32(grdResults.SelectedRow.Cells[0].Text);
                    }
                    else
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select a Row Width entry in the grid.");
                        throw (warn);
                    }
                }

                string rowWidth    = txtRowWidth.Text;
                string bpaFactor   = txtBPAFactor.Text;
                string standFactor = txtStandFactor.Text;

                WSCAdmin.PlantPopulationSave(plantPopulationID, Convert.ToInt32(ddlCropYear.SelectedValue), rowWidth, bpaFactor, standFactor, WSCSecurity.Identity);
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
        private void FillForm()
        {
            const string METHOD_NAME = "FillForm";

            try {
                ClearForm();

                int cropYear = Convert.ToInt32(((MasterReportTemplate)Master).CropYear);

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCAdmin.PassthroughAllGetByYear(conn, cropYear)) {
                        if (dr.Read())
                        {
                            int iFiscalYear   = dr.GetOrdinal("pssaFiscalYearEndDate");
                            int iPercentApply = dr.GetOrdinal("pssaPercentageToApply");
                            int iRatePerTon   = dr.GetOrdinal("pssaRatePerTon");
                            int iReportDate   = dr.GetOrdinal("pssaReportDate");
                            int iTaxYear      = dr.GetOrdinal("pssaTaxYear");

                            // Copy values into form
                            txtCropYear.Text          = cropYear.ToString();
                            txtFiscalYearEndDate.Text = dr.GetString(iFiscalYear);
                            txtPctToApply.Text        = dr.GetDecimal(iPercentApply).ToString("N3");
                            txtRatePerTon.Text        = dr.GetDecimal(iRatePerTon).ToString("N6");
                            txtReportDate.Text        = dr.GetString(iReportDate);
                            txtTaxYear.Text           = dr.GetInt32(iTaxYear).ToString();
                        }
                        else
                        {
                            Common.CWarning warn = new Common.CWarning(@"Before Printing you *MUST* set Coop values in Ag Admin\Passthrough Management for Crop Year "
                                                                       + cropYear.ToString());
                            throw(warn);
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Example #10
0
        private void DeletePlantPopulation()
        {
            const string METHOD_NAME = "DeletePlantPopulation";

            try {
                if (grdResults.SelectedRow == null)
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select a row width item in the grid before trying to Delete.");
                    throw (warn);
                }
                else
                {
                    int plantPopulationID = Convert.ToInt32(grdResults.SelectedRow.Cells[0].Text);
                    WSCAdmin.PlantPopulationDelete(plantPopulationID);
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Example #11
0
        private void FillResults(string filePath)
        {
            const string METHOD_NAME = "FillResults";
            DataSet      ds;
            decimal      dAmt;
            string       cntNo = "";
            string       amt   = "";
            string       ded   = "";

            string dbg = "0";

            try {
                string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=Excel 8.0;";
                dbg = "1";
                using (System.Data.OleDb.OleDbConnection xConn = new System.Data.OleDb.OleDbConnection(connStr)) {
                    dbg = "2";
                    xConn.Open();
                    dbg = "3";
                    ds  = new DataSet();
                    dbg = "4";
                    System.Data.OleDb.OleDbDataAdapter xAdapt = new System.Data.OleDb.OleDbDataAdapter("select Contract, Amount, Deduction from [Deductions$] where len(Contract) > 0", xConn);
                    dbg = "5";
                    xAdapt.Fill(ds);
                    dbg = "6";

                    // fix amounts
                    foreach (System.Data.DataRow dRow in ds.Tables[0].Rows)
                    {
                        try {
                            dbg   = "7";
                            cntNo = dRow["Contract"].ToString();
                            dbg   = "8";
                            if (cntNo.Length == 0)
                            {
                                break;
                            }
                            amt = dRow["Amount"].ToString();
                            dbg = "9";
                            ded = dRow["Deduction"].ToString();
                            dbg = "10";

                            dAmt           = Math.Round(Convert.ToDecimal(amt), 2);
                            dbg            = "11";
                            dRow["Amount"] = dAmt.ToString("#.00");
                            dbg            = "12";
                        }
                        catch (Exception ex) {
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Error processing the Amount, " + amt + ", for Contract " + cntNo + " with Deduction " + ded + ".", ex);
                            throw (warn);
                        }
                    }
                }

                // Save excel data into an XML document.
                string fileExt = System.IO.Path.GetExtension(filePath);
                dbg = "13";
                string xmlFilePath = filePath.Replace(fileExt, ".xml");
                dbg = "14";
                ds.WriteXml(xmlFilePath, System.Data.XmlWriteMode.IgnoreSchema);
                dbg = "15";

                // Retrieve the xml formatted input data and qualify it in the database.
                string xmlData = "";
                dbg = "16";
                int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                dbg = "17";

                // Retrieve the xml document of deductions: contract, amount, and deduction.
                using (System.IO.StreamReader reader = new StreamReader(xmlFilePath)) {
                    dbg     = "18";
                    xmlData = reader.ReadToEnd().Replace("\r\n", "");
                    dbg     = "19";
                }

                // Send to db to qualify
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    dbg = "20";
                    SqlDataReader dr = WSCAdmin.ContractDeductionQualify(conn, cropYear, xmlData);
                    dbg = "21";
                    // Load results into  grid
                    grdResults.DataSource = dr;
                    dbg = "22";
                    grdResults.DataBind(); dbg = "20";
                    dbg = "23";
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME
                                                              + "\filePath: " + filePath
                                                              + "\ndbg: " + dbg, ex);
                throw (wex);
            }
        }
Example #12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnSave_Click";
            int          taxYear     = 0;
            int          cropYear    = 0;
            bool         ok          = false;

            try {
                cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                taxYear  = Convert.ToInt32(Common.UILib.GetDropDownText(ddlTaxYear));

                string  tmp        = txtRatePerTon.Text;
                decimal ratePerTon = 0;
                if (!Decimal.TryParse(tmp, out ratePerTon))
                {
                    Common.CWarning warn = new Common.CWarning("Please enter a valid Rate Per Ton.");
                    throw (warn);
                }

                decimal percentToApply = 0;
                tmp = txtPercentageToApply.Text;
                if (!Decimal.TryParse(tmp, out percentToApply))
                {
                    Common.CWarning warn = new Common.CWarning("Please enter a valid Percentage to Apply.");
                    throw (warn);
                }

                DateTime reportDate = DateTime.MinValue;
                tmp = txtReportDate.Text;
                if (tmp != "")
                {
                    if (!DateTime.TryParse(tmp, out reportDate))
                    {
                        Common.CWarning warn = new Common.CWarning("Please enter a valid Report Date.");
                        throw (warn);
                    }
                }

                DateTime fiscalYearEndDate = DateTime.MinValue;
                tmp = txtFiscalYearEndDate.Text;
                if (tmp != "")
                {
                    if (!DateTime.TryParse(tmp, out fiscalYearEndDate))
                    {
                        Common.CWarning warn = new Common.CWarning("Please enter a valid Fiscal Year End Date.");
                        throw (warn);
                    }
                }

                WSCAdmin.PassthroughAllSave(cropYear, taxYear, ratePerTon, percentToApply,
                                            reportDate, fiscalYearEndDate, Globals.SecurityState.UserName);

                ok = true;
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }

            if (ok)
            {
                Response.Redirect("~/Admin/PassthroughManagement.aspx?YR=" + cropYear.ToString()
                                  + "&UpdateOk=true");
            }
        }