Exemplo n.º 1
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnFind_Click";
            string       shid        = txtSHID.Text;

            try {
                if (!Common.CodeLib.IsValidSHID(shid))
                {
                    divNurseryNorth.Attributes.Add("class", "DisplayOff");
                    divNurserySouth.Attributes.Add("class", "DisplayOff");

                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid SHID.");
                    throw (warn);
                }
                ClearResults();
                FindAddress(shid);
                SetupNorthSouth();
            }
            catch (Exception ex) {
                divNurseryNorth.Attributes.Add("class", "DisplayOff");
                divNurserySouth.Attributes.Add("class", "DisplayOff");
                ResetShareholder();
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 2
0
        protected void btnDeleteDeduction_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnDeleteDeduction_Click";

            try {
                // Switch Grids
                GridViewRow row = grdEqDeduction.SelectedRow;
                if (row == null)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Delete, please select an row from the Member Equity Deduction grid.");
                    throw (warn);
                }
                int    equityDeductionMemberID = Convert.ToInt32(row.Cells[(int)EqDedGridCols.colMemberEquityDeductionID].Text);
                string rowVersion = row.Cells[(int)EqDedGridCols.colRowVersion].Text;

                BeetEquityDeduction.EquityDeductionMemberDelete(equityDeductionMemberID, rowVersion);

                ClearEdit();
                int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                FillGridEqDeduction(MySHID, cropYear);
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 3
0
        protected void btnTestFromEmail_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnTestFromEmail_Click";

            try {
                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 (txtToTest.Text.Length == 0)
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Test To Email Address.");
                    throw (warn);
                }
                if (!Common.CodeLib.ValidateEmail(txtToTest.Text))
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid Test To Email Address.");
                    throw (warn);
                }

                string pathAttach = "";
                foreach (ListItem li in lstAttach.Items)
                {
                    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;
                        }
                    }
                }

                Common.AppHelper.SendEmailWithAttach(
                    ConfigurationManager.AppSettings["email.smtpServer"].ToString(),
                    ConfigurationManager.AppSettings["email.smtpServerPort"].ToString(),
                    ConfigurationManager.AppSettings["email.smtpUser"].ToString(),
                    ConfigurationManager.AppSettings["email.smtpPassword"].ToString(),
                    txtFromEmail.Text, txtToTest.Text, "",
                    "",
                    "Test - Send File (Check From Email Address)", "This is a successful test.", pathAttach);

                Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please check that a Test email was received at your Test To Email Address.");
                txtContinueBatch.Value = "";
            }
            catch (Exception ex) {
                txtContinueBatch.Value = "";
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 4
0
        protected void btnDeletePDF_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnDeletePDF_Click";

            try {
                //------------------------------------------
                // Delete the PDF File.
                //------------------------------------------
                string locLastPdf = ((MasterReportTemplate)Page.Master).LocLastPDF;
                string fileName   = Page.MapPath(locLastPdf);

                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Successfully deleted " + fileName + ".");
                }
                else
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("PDF file not found on file system.");
                    throw (warn);
                }
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
0
        protected void btnDeletePDF_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnDeletePDF_Click";

            try {

                //------------------------------------------
                // Delete the PDF File.
                //------------------------------------------
                string locLastPdf = ((MasterReportTemplate)Page.Master).LocLastPDF;
                string fileName = Page.MapPath(locLastPdf);

                if (System.IO.File.Exists(fileName)) {
                    System.IO.File.Delete(fileName);
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Successfully deleted " + fileName + ".");
                } else {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("PDF file not found on file system.");
                    throw (warn);
                }

            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((MasterReportTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 7
0
        public static SqlDataReader SecurityRegionGetAll(SqlConnection conn)
        {
            const string  METHOD_NAME = MOD_NAME + "SecurityRegionGetAll.";
            SqlDataReader dr          = null;

            try {
                string procName = "bawpRegionGetAll";

                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();
                }

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName);
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                    {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    }
                    else
                    {
                        throw (sqlEx);
                    }
                }
            }
            catch (System.Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wscEx);
            }

            return(dr);
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            const string METHOD_NAME = "Page_Load";

            try {
                Common.AppHelper.HideWarning((HtmlGenericControl)Master.FindControl("divWarning"));
                _shs = Globals.ShsData;

                if (Globals.IsUserPermissionReadOnly((RolePrincipal)User))
                {
                    btnChange.Enabled = false;
                }

                if (!Common.CodeLib.IsValidSHID(txtSHID.Text))
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid SHID and press the Find button.");
                    throw (warn);
                }

                if (!Page.IsPostBack)
                {
                    FillCropYear();
                    FindAddress(_shs.SHID.ToString());
                }
            }
            catch (System.Exception ex) {
                ResetShareholder();
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 9
0
        public static Contract GetContract(int contractNo, int cropYear)
        {
            const string METHOD_NAME = "GetContract";

            Contract contract = null;

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "s70cnt_GetContract";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = contractNo;
                    spParams[1].Value = cropYear;

                    try {

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                            int iContarctID = dr.GetOrdinal("cnt_contract_id");
                            int iCropYear = dr.GetOrdinal("cnt_crop_year");
                            int iContractNo = dr.GetOrdinal("cnt_contract_no");
                            int iFactoryId = dr.GetOrdinal("cnt_factory_id");
                            int iPACDues = dr.GetOrdinal("cnt_pack_dues");

                            while (dr.Read()) {
                                int contractId = dr.GetInt32(iContarctID);
                                int crop_year = Convert.ToInt32(dr.GetDateTime(iCropYear).Year);
                                int contract_no = Convert.ToInt32(dr.GetString(iContractNo));
                                int factory_id = dr.GetInt32(iFactoryId);
                                double pac_dues = Convert.ToDouble(dr.GetDecimal(iPACDues));
                                contract = new Contract(contractId, crop_year, contract_no, factory_id, pac_dues);
                            }
                        }
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            string errMsg = MOD_NAME + METHOD_NAME;
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return contract;
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        public static SqlDataReader GetEmailByShid(SqlConnection conn, string shidList, int cropYear, bool SubYesActYes, bool SubYesActNo,
                                                   bool SubNoActYes, bool isInternalOnly, bool isExternalOnly)
        {
            SqlDataReader dr = null;

            try {
                string procName = "bawpAddressEmailGetByShid";

                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();
                }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = shidList;
                spParams[1].Value = cropYear;
                spParams[2].Value = SubYesActYes;
                spParams[3].Value = SubYesActNo;
                spParams[4].Value = SubNoActYes;
                spParams[5].Value = isInternalOnly;
                spParams[6].Value = isExternalOnly;
                SetTimeout();

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                    {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    }
                    else
                    {
                        string errMsg = MOD_NAME + "UserFindLogon";
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {
                if (dr != null && !dr.IsClosed)
                {
                    dr.Close();
                }
                string errMsg = MOD_NAME + "UserFindLogon";
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return(dr);
        }
Exemplo n.º 12
0
        public static bool IsMemberAgriculturist(int userID, int shid, int cropYear)
        {
            const string METHOD_NAME = "IsMemberAgriculturist";
            string errMsg = "";

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpEmpIsMemAgriculturist";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = userID;
                    spParams[1].Value = shid;
                    spParams[2].Value = cropYear;
                    SetTimeout();

                    SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);

                    if (spParams[3].Value == System.DBNull.Value) {
                        return false;
                    } else {
                        return Convert.ToBoolean(spParams[3].Value);
                    }
                }
            }
            catch (SqlException sqlEx) {

                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                } else {
                    errMsg = MOD_NAME + METHOD_NAME + LF +
                        "UserID: " + userID.ToString() +
                        "SHID: " + shid.ToString() +
                        "CropYear: " + cropYear.ToString();
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {

                if (errMsg.Length == 0)  {

                    errMsg = MOD_NAME + METHOD_NAME + LF +
                        "UserID: " + userID.ToString() +
                        "SHID: " + shid.ToString() +
                        "CropYear: " + cropYear.ToString();
                } else {errMsg = "";}

                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 13
0
        protected void btnUpdateDeduction_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnUpdateDeduction_Click";

            try {
                GridViewRow row = grdPayment.SelectedRow;
                if (row == null)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Update, please select a Payment from the Available Equity Payments grid.");
                    throw (warn);
                }

                //--------------------------------------------------
                // Marry a Member to a Deduction and a payment.
                //--------------------------------------------------
                int    equityCropYear    = Convert.ToInt32(row.Cells[(int)PaymentGridCols.colEquityCropYear].Text);
                string equityType        = row.Cells[(int)PaymentGridCols.colEquityType].Text;
                int    sequence          = Convert.ToInt32(row.Cells[(int)PaymentGridCols.colSequence].Text);
                string paymentDesc       = row.Cells[(int)PaymentGridCols.colPaymentDesc].Text;
                int    equityDeductionID = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlEquityDeductions));
                int    memberID          = Convert.ToInt32(MyMemberID);
                int    cropYear          = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));

                // Switch Grids
                row = grdEqDeduction.SelectedRow;
                if (row == null)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Update, please select an row from the Member Equity Deduction grid.");
                    throw (warn);
                }
                int    equityDeductionMemberID = Convert.ToInt32(row.Cells[(int)EqDedGridCols.colMemberEquityDeductionID].Text);
                string rowVersion = row.Cells[(int)EqDedGridCols.colRowVersion].Text;

                string  amountText      = txtDeductionAmount.Text.TrimEnd().Replace(BLANK_CELL, "");
                decimal deductionAmount = 0;
                try {
                    deductionAmount = Convert.ToDecimal(amountText);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a positive number for Deduction Amount.");
                    throw (warn);
                }

                string   userName      = Common.AppHelper.GetIdentityName();
                DateTime deductionDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                BeetEquityDeduction.EquityDeductionMemberSave(equityDeductionMemberID, memberID, equityDeductionID,
                                                              equityCropYear, cropYear, equityType, sequence, paymentDesc, deductionAmount, deductionDate, rowVersion, userName);

                ClearEdit();
                FillGridEqDeduction(MySHID, cropYear);
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 14
0
        public static int SavePACAgreement(PACAgreement pacAgreement)
        {
            const string METHOD_NAME = "SavePACAgreement";
            int          pacId       = 0;

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "pacAgreement_Save";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[1].Value = pacAgreement.SHID;
                    spParams[2].Value = pacAgreement.Contribution;
                    spParams[3].Value = pacAgreement.PACDate;
                    spParams[4].Value = pacAgreement.PACCropYear;
                    spParams[5].Value = pacAgreement.IndividualsString;

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();

                            pacId = Convert.ToInt16(spParams[0].Value);
                        } catch (SqlException sqlEx) {
                            if (tran != null)
                            {
                                tran.Rollback();
                            }

                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                            {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            }
                            else
                            {
                                string errMsg = MOD_NAME;
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return(pacId);
        }
Exemplo n.º 15
0
        public static void GetMemberInfo(string shid, int cropYear, ref int memberID, ref int addressID, ref string busName, ref string phone, ref string email, ref string fax,
                                         ref int factoryID, ref int factoryNumber, ref string factoryName)
        {
            const string METHOD_NAME = "GetMemberInfo";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpMemberGetBeetInfo";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    // Manually synch these fields with database.
                    int imemberID = 0, iaddressID = 1, ibusname = 2, ipone = 3, iemail = 4, ifax = 5, ifactoryID = 6, ifactoryNumber = 7, ifactoryName = 8;
                    spParams[0].Value = shid;
                    spParams[1].Value = cropYear;

                    using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                        if (dr.Read())
                        {
                            memberID      = dr.GetInt32(imemberID);
                            addressID     = dr.GetInt32(iaddressID);
                            busName       = dr.GetString(ibusname);
                            phone         = dr.GetString(ipone);
                            email         = dr.GetString(iemail);
                            fax           = dr.GetString(ifax);
                            factoryID     = dr.GetInt32(ifactoryID);
                            factoryNumber = dr.GetInt32(ifactoryNumber);
                            factoryName   = dr.GetString(ifactoryName);
                        }
                    }
                }
            }
            catch (SqlException sqlEx) {
                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                }
                else
                {
                    string errMsg = MOD_NAME + METHOD_NAME + LF + "SHID: " + shid;
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME + LF + "SHID: " + shid;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 16
0
        public static void UserSave(ref int userID,
                                    string userName, string displayName, string phoneNumber, string UserName)
        {
            const string METHOD_NAME = "UserSave";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpUserSave";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[1].Value = userID;
                    spParams[2].Value = userName;
                    spParams[3].Value = displayName;
                    spParams[4].Value = phoneNumber;
                    spParams[5].Value = UserName;
                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();

                            userID = Convert.ToInt32(spParams[0].Value);
                        }
                        catch (SqlException sqlEx) {
                            if (tran != null)
                            {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                            {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            }
                            else
                            {
                                string errMsg = MOD_NAME + METHOD_NAME;
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 17
0
        public static List <ListOverPlantFactoryItem> OverPlantFactoryByYear(int cropYear)
        {
            const string METHOD_NAME = "OverPlantFactoryByYear";

            List <ListOverPlantFactoryItem> state = new List <ListOverPlantFactoryItem>();

            try {
                string procName = "bawpOverPlantFactoryByYear";

                try {
                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                        if (conn.State != System.Data.ConnectionState.Open)
                        {
                            conn.Open();
                        }
                        System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                        spParams[0].Value = cropYear;

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                            int iftyNum           = dr.GetOrdinal("fty_factory_no");
                            int iftyName          = dr.GetOrdinal("fty_name");
                            int iisOverPlantAllow = dr.GetOrdinal("IsOverPlantAllowed");
                            int ipct            = dr.GetOrdinal("PctOverPlant");
                            int iisPoolAllowed  = dr.GetOrdinal("IsPoolAllowed");
                            int ipoolShid       = dr.GetOrdinal("PoolingSHID");
                            int ipoolCutoffDate = dr.GetOrdinal("PoolCutoffDate");
                            int iisPosted       = dr.GetOrdinal("IsPosted");

                            while (dr.Read())
                            {
                                state.Add(new ListOverPlantFactoryItem(dr.GetString(iftyNum), dr.GetString(iftyName), dr.GetBoolean(iisOverPlantAllow),
                                                                       dr.GetDecimal(ipct), dr.GetBoolean(iisPoolAllowed), dr.GetString(ipoolShid), dr.GetString(ipoolCutoffDate), dr.GetBoolean(iisPosted)));
                            }
                        }
                    }
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                    {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    }
                    else
                    {
                        throw (sqlEx);
                    }
                }
            }
            catch (System.Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wscEx);
            }

            return(state);
        }
Exemplo n.º 18
0
        public static List <Individual> GetPACIndividuals(int id, string name)
        {
            const string METHOD_NAME = "GetPACIndividuals";

            List <Individual> individuals = new List <Individual>();

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "pacIndividual_Get";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = id;
                    spParams[1].Value = (name != null ? name.ToLower() : null);

                    try {
                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                            while (dr.Read())
                            {
                                individuals.Add(new Individual {
                                    IndividualID = Convert.ToInt32(dr["individual_id"] ?? 0),
                                    FullName     = dr["full_name"].ToString(),
                                    Email        = (dr["email"] == null) ? "" : dr["email"].ToString(),
                                    SHID         = (dr["shid"].ToString() == "") ? 0 : Convert.ToInt32(dr["shid"].ToString())
                                });
                            }
                        }
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                        {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        }
                        else
                        {
                            string errMsg = MOD_NAME + METHOD_NAME;
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return(individuals);
        }
Exemplo n.º 19
0
        public static void GetMemberInfo(string shid, int cropYear, ref int memberID, ref int addressID, ref string busName, ref string phone, ref string email, ref string fax,
                ref int factoryID, ref int factoryNumber, ref string factoryName)
        {
            const string METHOD_NAME = "GetMemberInfo";

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpMemberGetBeetInfo";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    // Manually synch these fields with database.
                    int imemberID = 0, iaddressID = 1, ibusname = 2, ipone = 3, iemail = 4, ifax = 5, ifactoryID = 6, ifactoryNumber = 7, ifactoryName = 8;
                    spParams[0].Value = shid;
                    spParams[1].Value = cropYear;

                    using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                        if (dr.Read()) {

                            memberID = dr.GetInt32(imemberID);
                            addressID = dr.GetInt32(iaddressID);
                            busName = dr.GetString(ibusname);
                            phone = dr.GetString(ipone);
                            email = dr.GetString(iemail);
                            fax = dr.GetString(ifax);
                            factoryID = dr.GetInt32(ifactoryID);
                            factoryNumber = dr.GetInt32(ifactoryNumber);
                            factoryName = dr.GetString(ifactoryName);

                        }
                    }
                }
            }
            catch (SqlException sqlEx) {

                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                } else {
                    string errMsg = MOD_NAME + METHOD_NAME + LF + "SHID: " + shid;
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {

                string errMsg = MOD_NAME + METHOD_NAME + LF + "SHID: " + shid;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 20
0
        public static void SplitShidList(string shid, out string shidList, out string shidLo, out string shidHi)
        {
            const string METHOD_NAME = "SplitShidList";

            // Now we have one or more shids.
            shidList = "";
            shidLo   = "";
            shidHi   = "";

            // First squeeze out any blanks
            string shidTest = shid.Replace(" ", "");

            try {
                // CSV check -- string has a "," character
                if (shidTest.IndexOf(",") != -1)
                {
                    // Cannot ALSO have an embedded dash "-"
                    if (shidTest.IndexOf("-") != -1)
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You can enter a list or a range of SHIDs but not both.");
                        throw (warn);
                    }
                    else
                    {
                        shidList = shidTest;
                    }
                }
                else
                {
                    // Range check -- string has a dash separating the low/high values.
                    if (shidTest.IndexOf("-") != -1)
                    {
                        string[] shidParts = shidTest.Split(new char[] { '-' });
                        if (shidParts.Length != 2)
                        {
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Range not entered correctly.  You indicate a range by placing a dash between a low value of SHID and a higher value of SHID.");
                            throw (warn);
                        }

                        shidLo = shidParts[0];
                        shidHi = shidParts[1];
                    }
                    else
                    {
                        // No comma and no dash, must be a sigle shid specified.
                        shidList = shidTest;
                    }
                }
            }
            catch (Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 21
0
        public static void AppErrorInfoCreate(int appErrorInfoID, string appName, DateTime errorDate,
                                              string serverName, string clientName, string loginName, string errorCode, string userName, string errorText)
        {
            const string METHOD_NAME = "AppErrorInfoCreate";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "srspAppErrorInfoSave";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = appErrorInfoID;
                    spParams[1].Value = appName;
                    spParams[2].Value = errorDate;
                    spParams[3].Value = "O";
                    spParams[4].Value = serverName;
                    spParams[5].Value = clientName;
                    spParams[6].Value = loginName;
                    spParams[7].Value = errorCode;
                    spParams[8].Value = userName;
                    spParams[9].Value = errorText;

                    try {
                        using (SqlTransaction tran = conn.BeginTransaction()) {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                        {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        }
                        else
                        {
                            string errMsg = MOD_NAME + METHOD_NAME;
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 22
0
        public static void PlantPopulationSave(int plantPopulationID, int cropYear, string rowWidth,
                                               string bpaFactor, string standFactor, string userName)
        {
            const string METHOD_NAME = "PlantPopulationSave";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpPlantPopulationSave";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[1].Value = plantPopulationID;
                    spParams[2].Value = cropYear;
                    spParams[3].Value = Convert.ToInt32((rowWidth.Length == 0 ? "0" : rowWidth));
                    spParams[4].Value = Convert.ToDecimal((bpaFactor.Length == 0 ? "0" : bpaFactor));
                    spParams[5].Value = Convert.ToDecimal((standFactor.Length == 0 ? "0" : standFactor));
                    spParams[6].Value = userName.Substring(0, (userName.Length > 20 ? 20 : userName.Length));

                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {
                            if (tran != null)
                            {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                            {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            }
                            else
                            {
                                throw (sqlEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 23
0
        public static void LookupSave(
            string lookupType, bool lookupIsActive, string lookupOldDescription,
            string lookupDescription, bool fixOldValues)
        {
            const string METHOD_NAME = "LookupSave";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpLookupSave";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = lookupType;
                    spParams[1].Value = lookupIsActive;
                    spParams[2].Value = lookupOldDescription;
                    spParams[3].Value = lookupDescription;
                    spParams[4].Value = fixOldValues;

                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {
                            if (tran != null)
                            {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                            {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            }
                            else
                            {
                                throw (sqlEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 24
0
        public static void OverPlantFactorySave(int cropYear, int factoryNumber, bool isOverPlantAllowed, decimal overPlantPct, bool isPoolingAllowed, int poolMemberSHID,
                                                string poolCutoffDate, string userName)
        {
            const string METHOD_NAME = "OverPlantFactorySave";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpOverPlantFactorySave";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = cropYear;
                    spParams[1].Value = factoryNumber;
                    spParams[2].Value = isOverPlantAllowed;
                    spParams[3].Value = overPlantPct;
                    spParams[4].Value = isPoolingAllowed;
                    spParams[5].Value = poolMemberSHID;
                    if (poolCutoffDate.Length > 0)
                    {
                        spParams[6].Value = poolCutoffDate;
                    }
                    else
                    {
                        spParams[6].Value = DBNull.Value;
                    }
                    spParams[7].Value = userName;

                    try {
                        SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                        {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        }
                        else
                        {
                            throw (sqlEx);
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 25
0
        public static void BankPayeeSaveOtherYear(int bankID,
                                                  int addressID, bool subRecd, int otherCropYear, bool isInsert, string UserName)
        {
            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpBankPayeeSaveOtherYear";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = bankID;
                    spParams[1].Value = addressID;
                    spParams[2].Value = subRecd;
                    spParams[3].Value = otherCropYear;
                    spParams[4].Value = isInsert;
                    spParams[5].Value = UserName;
                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {
                            if (tran != null)
                            {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                            {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            }
                            else
                            {
                                string errMsg = MOD_NAME + "BankPayeeSaveOtherYear";
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + "BankPayeeSaveOtherYear";
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 26
0
        public static List<ListOverPlantFactoryItem> OverPlantFactoryByNumber(int cropYear, int factoryNumber)
        {
            const string METHOD_NAME = "OverPlantFactoryByNumber";

            List<ListOverPlantFactoryItem> state = new List<ListOverPlantFactoryItem>();

            try {

                string procName = "bawpOverPlantFactoryByNumber";

                try {

                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                        if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                        System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                        spParams[0].Value = cropYear;
                        spParams[1].Value = factoryNumber;

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                            int iftyNum = dr.GetOrdinal("FactoryNumber");
                            int iftyName = dr.GetOrdinal("FactoryName");
                            int iisOverPlantAllow = dr.GetOrdinal("IsOverPlantAllowed");
                            int ipct = dr.GetOrdinal("OverPlantPct");
                            int iisPoolAllowed = dr.GetOrdinal("IsPoolAllowed");
                            int ipoolCutoffDate = dr.GetOrdinal("PoolCutoffDate");

                            if (dr.Read()) {

                                state.Add(new ListOverPlantFactoryItem(dr.GetInt32(iftyNum).ToString(), dr.GetString(iftyName), dr.GetBoolean(iisOverPlantAllow),
                                    dr.GetDecimal(ipct), dr.GetBoolean(iisPoolAllowed), "", dr.GetString(ipoolCutoffDate), false));
                            }
                        }
                    }
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        throw (sqlEx);
                    }
                }
            }
            catch (System.Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wscEx);
            }

            return state;
        }
Exemplo n.º 27
0
        public static void UpdatePassword(int memberID, string oldPassword, string newPassword, ref bool isSuccess)
        {
            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpUserUpdatePassword";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = memberID;
                    spParams[1].Value = oldPassword;
                    spParams[2].Value = newPassword;
                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            isSuccess = Convert.ToBoolean(spParams[3].Value);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {
                            if (tran != null)
                            {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                            {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            }
                            else
                            {
                                string errMsg = "Error in " + MOD_NAME + "UpdatePassword" + LF +
                                                "Description: " + sqlEx.Message;
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = "Error in " + MOD_NAME + "UpdatePassword" + LF +
                                "Description: " + e.Message;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 28
0
        public static List <ListEquityPaymentScheduleItem> EquityPaymentSchedule(int cropYear)
        {
            const string METHOD_NAME = "EquityPaymentSchedule";
            List <ListEquityPaymentScheduleItem> state = new List <ListEquityPaymentScheduleItem>();

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpEquityPaymentSchedule";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    // Manually synch these fields with database.
                    spParams[0].Value = cropYear;

                    using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                        int igroupType  = dr.GetOrdinal("GroupType");
                        int iequityType = dr.GetOrdinal("EquityType");
                        int ipayDate    = dr.GetOrdinal("PayDate");

                        while (dr.Read())
                        {
                            state.Add(new ListEquityPaymentScheduleItem(0, dr.GetString(igroupType), dr.GetString(iequityType),
                                                                        "", dr.GetString(ipayDate)));
                        }
                    }
                }

                return(state);
            }
            catch (SqlException sqlEx) {
                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                }
                else
                {
                    string errMsg = MOD_NAME + METHOD_NAME;
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 29
0
        public static SqlDataReader ContractDeductionQualify(SqlConnection conn, int cropYear, string xmlDataMap)
        {
            SqlDataReader dr          = null;
            const string  METHOD_NAME = "ContractDeductionQualify";

            try {
                string procName = "bawpContractDeductionQualify";

                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();
                }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = cropYear;
                spParams[1].Value = xmlDataMap;
                SetTimeout();

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                    {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    }
                    else
                    {
                        string errMsg = MOD_NAME + METHOD_NAME;
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {
                if (dr != null && !dr.IsClosed)
                {
                    dr.Close();
                }
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return(dr);
        }
Exemplo n.º 30
0
        public static List <ListBeetFactoryIDItem> BeetFactoryIDGetList(int cropYear)
        {
            const string METHOD_NAME           = "BeetFactoryIDGetList";
            List <ListBeetFactoryIDItem> state = new List <ListBeetFactoryIDItem>();

            try {
                string procName = "bawpFactoryGetAll";

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = cropYear;

                    using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                        int iFtyID     = dr.GetOrdinal("fty_factory_id");
                        int iFtyNumber = dr.GetOrdinal("fty_factory_no");
                        int iFtyName   = dr.GetOrdinal("fty_name");

                        while (dr.Read())
                        {
                            state.Add(new ListBeetFactoryIDItem(dr.GetInt32(iFtyID), Convert.ToInt32(dr.GetInt16(iFtyNumber)), dr.GetString(iFtyName)));
                        }
                    }
                }

                return(state);
            }
            catch (SqlException sqlEx) {
                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                }
                else
                {
                    string errMsg = MOD_NAME + METHOD_NAME;
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);

                throw (wscEx);
            }
        }
Exemplo n.º 31
0
        public static SqlDataReader BankFindNumber(SqlConnection conn, string bankNumber, bool isActive)
        {
            SqlDataReader dr = null;

            try {
                string procName = "bawpBankFindByNumber";

                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();
                }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = bankNumber;
                spParams[1].Value = isActive;
                SetTimeout();

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (dr != null && !dr.IsClosed)
                    {
                        dr.Close();
                    }
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                    {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    }
                    else
                    {
                        string errMsg = MOD_NAME + "BankFindNumber";
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {
                if (dr != null && !dr.IsClosed)
                {
                    dr.Close();
                }
                string errMsg = MOD_NAME + "BankFindNumber";
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return(dr);
        }
Exemplo n.º 32
0
        /*
         * Get List of contracts by type:
         *  0 - SHID
         *  1 - Business Name
         *  2 - Last Name
         *  3 - Contract Number
         */
        public static List <Contract> GetContracts(string searchTerm, int cropYear, int iType)
        {
            const string METHOD_NAME = "GetSHIDContracts";

            List <Contract> contracts = new List <Contract>();

            try {
                string procName = "s70cnt_Find";

                try {
                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                        if (conn.State != System.Data.ConnectionState.Open)
                        {
                            conn.Open();
                        }
                        System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                        spParams[0].Value = searchTerm;
                        spParams[1].Value = cropYear;
                        spParams[2].Value = iType;

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {
                            int iContractNo = dr.GetOrdinal("contractNo");

                            while (dr.Read())
                            {
                                int contractNo = Convert.ToInt32(dr.GetString(iContractNo));
                                contracts.Add(GetContract(contractNo, cropYear));
                            }
                        }
                    }
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                    {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    }
                    else
                    {
                        throw (sqlEx);
                    }
                }
            }
            catch (System.Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wscEx);
            }

            return(contracts);
        }
Exemplo n.º 33
0
        public static void EquityDeductionMemberSave(int equityDeductionMemberID, int memberID, int equityDeductionID, int equityCropYear, int cropYear,
                                                     string equityType, int sequence, string paymentDesc, decimal deductionAmount, DateTime deductionDate, string rowVersion, string userName)
        {
            const string METHOD_NAME = "EquityDeductionMemberSave";

            try {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    string procName = "bawpEquityDeductionMemberSave";

                    if (conn.State != System.Data.ConnectionState.Open)
                    {
                        conn.Open();
                    }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value  = equityDeductionMemberID;
                    spParams[1].Value  = memberID;
                    spParams[2].Value  = equityDeductionID;
                    spParams[3].Value  = equityCropYear;
                    spParams[4].Value  = cropYear;
                    spParams[5].Value  = equityType;
                    spParams[6].Value  = sequence;
                    spParams[7].Value  = paymentDesc;
                    spParams[8].Value  = deductionAmount;
                    spParams[9].Value  = deductionDate;
                    spParams[10].Value = rowVersion;
                    spParams[11].Value = userName;

                    SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);
                }
            }
            catch (SqlException sqlEx) {
                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning))
                {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                }
                else
                {
                    string errMsg = MOD_NAME + METHOD_NAME;
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 34
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnAdd_Click";

            try {
                //----------------------------------------------------------------------
                // Use the constructor to clean up state values, especially from grid.
                //----------------------------------------------------------------------
                ListEquityDeductionItem state = new ListEquityDeductionItem(
                    "",
                    txtEDedNumber.Text,
                    txtEDedDescription.Text,
                    (chkEDedIsActive.Checked ? "Y" : "N"),
                    "");


                string tmpNum          = state.DeductionNumber;
                int    deductionNumber = 0;
                try {
                    deductionNumber = Convert.ToInt32(tmpNum);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a positive number for Deduction Number.");
                    throw (warn);
                }
                if (deductionNumber == 0)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Number to a number greater than zero.");
                    throw (warn);
                }

                if (state.DeductionDescription.Length == 0)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Description.");
                    throw (warn);
                }

                string userName = Common.AppHelper.GetIdentityName();

                BeetEquityDeduction.EquityDeductionSave(Convert.ToInt32(state.EquityDeductionID), Convert.ToInt32(state.DeductionNumber),
                                                        state.DeductionDescription, state.IsActiveAsBool(), state.RowVersion, userName);

                ResetEquityDeductionEdit();
                FillEqDeductionGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 35
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnDelete_Click";

            try {
                //------------------------------------
                // Pull info from grid selection.
                //------------------------------------
                GridViewRow row = grdEqDeduction.SelectedRow;
                if (row == null)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Delete, please select an Equity Deduction from the Equity Deductions grid.");
                    throw (warn);
                }

                //----------------------------------------------------------------------
                // Use the constructor to clean up state values, especially from grid.
                //----------------------------------------------------------------------
                ListEquityDeductionItem state = new ListEquityDeductionItem(
                    row.Cells[(int)EqDedGridCols.colEquityDeductionID].Text,
                    txtEDedNumber.Text,
                    txtEDedDescription.Text,
                    (chkEDedIsActive.Checked ? "Y" : "N"),
                    row.Cells[(int)EqDedGridCols.colRowVersion].Text);

                int equityDeductionID = Convert.ToInt32(state.EquityDeductionID);
                if (equityDeductionID <= 0)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Unable to identify your Equity Deductions grid selection.  Try making your selection again.");
                    throw (warn);
                }

                string rowVersion = state.RowVersion;
                if (rowVersion.Length == 0)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Unable to identify your Equity Deductions grid selection.  Try making your selection again.");
                    throw (warn);
                }

                BeetEquityDeduction.EquityDeductionDelete(equityDeductionID, rowVersion);

                ResetEquityDeductionEdit();
                FillEqDeductionGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 36
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnAdd_Click";

            try {

                //----------------------------------------------------------------------
                // Use the constructor to clean up state values, especially from grid.
                //----------------------------------------------------------------------
                ListEquityDeductionItem state = new ListEquityDeductionItem(
                    "",
                    txtEDedNumber.Text,
                    txtEDedDescription.Text,
                    (chkEDedIsActive.Checked ? "Y" : "N"),
                    "");

                string tmpNum = state.DeductionNumber;
                int deductionNumber = 0;
                try {
                    deductionNumber = Convert.ToInt32(tmpNum);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a positive number for Deduction Number.");
                    throw (warn);
                }
                if (deductionNumber == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Number to a number greater than zero.");
                    throw (warn);
                }

                if (state.DeductionDescription.Length == 0) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a Deduction Description.");
                    throw (warn);
                }

                string userName = Common.AppHelper.GetIdentityName();

                BeetEquityDeduction.EquityDeductionSave(Convert.ToInt32(state.EquityDeductionID), Convert.ToInt32(state.DeductionNumber),
                    state.DeductionDescription, state.IsActiveAsBool(), state.RowVersion, userName);

                ResetEquityDeductionEdit();
                FillEqDeductionGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 37
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);
            }
        }
Exemplo n.º 38
0
        protected void btnAddDeduction_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnAddDeduction_Click";

            try {

                GridViewRow row = grdPayment.SelectedRow;
                if (row == null) {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Before pressing Add, please select a Payment from the Available Equity Payments grid.");
                    throw (warn);
                }

                //--------------------------------------------------
                // Marry a Member to a Deduction and a payment.
                //--------------------------------------------------
                int equityCropYear = Convert.ToInt32(row.Cells[(int)PaymentGridCols.colEquityCropYear].Text);
                string equityType = row.Cells[(int)PaymentGridCols.colEquityType].Text;
                int sequence = Convert.ToInt32(row.Cells[(int)PaymentGridCols.colSequence].Text);
                string paymentDesc = row.Cells[(int)PaymentGridCols.colPaymentDesc].Text;
                int equityDeductionID = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlEquityDeductions));
                int memberID = Convert.ToInt32(MyMemberID);
                int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));

                string amountText = txtDeductionAmount.Text.TrimEnd().Replace(BLANK_CELL, "");
                decimal deductionAmount = 0;
                try {
                    deductionAmount = Convert.ToDecimal(amountText);
                }
                catch {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a positive number for Deduction Amount.");
                    throw (warn);
                }

                string userName = Common.AppHelper.GetIdentityName();
                DateTime deductionDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                BeetEquityDeduction.EquityDeductionMemberSave(0, memberID, equityDeductionID,
                    equityCropYear, cropYear, equityType, sequence, paymentDesc, deductionAmount, deductionDate, "", userName);

                ClearEdit();
                FillGridEqDeduction(MySHID, cropYear);
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemplo n.º 39
0
        public static SqlDataReader AddressFindName(SqlConnection conn, string addressName)
        {
            const string METHOD_NAME = "AddressFindName";
            SqlDataReader dr = null;

            try {

                string procName = "bawpAddressFindByName";

                if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = addressName;
                SetTimeout();

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (dr != null && !dr.IsClosed) {
                        dr.Close();
                    }
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        string errMsg = MOD_NAME + METHOD_NAME;
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {
                if (dr != null && !dr.IsClosed) {
                    dr.Close();
                }
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }

            return dr;
        }
Exemplo n.º 40
0
        public static void BankDelete(int bankID, string UserName)
        {
            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpBankDelete";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = bankID;
                    spParams[1].Value = UserName;
                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {

                            if (tran != null) {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            } else {
                                string errMsg = MOD_NAME + "BankDelete";
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + "BankDelete";
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 41
0
        public static void GetAddress(int memberID,
            ref string email, ref string fax, ref string busName)
        {
            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpUserGetAddress";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = memberID;
                    SetTimeout();

                    SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);

                    email = spParams[1].Value.ToString();
                    fax = spParams[2].Value.ToString();
                    busName = spParams[3].Value.ToString();
                }
            }
            catch (SqlException sqlEx) {

                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                } else {
                    string errMsg = MOD_NAME + "GetAddress";
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {

                string errMsg = MOD_NAME + "GetAddress";
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 42
0
        public static void AppErrorFileDelete(int appErrorInfoID)
        {
            const string METHOD_NAME = "AppErrorFileDelete";

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "srspAppErrorInfoDelete";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = appErrorInfoID;

                    try {
                        using (SqlTransaction tran = conn.BeginTransaction()) {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            string errMsg = MOD_NAME + METHOD_NAME;
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 43
0
        public static void DirectDeliveryContractDelete(int directDeliveryID, int cropYear, int contractID, string rowVersion)
        {
            const string METHOD_NAME = "DirectDeliveryContractDelete";

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpDirectDeliveryContractDelete";
                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = directDeliveryID;
                    spParams[1].Value = cropYear;
                    spParams[2].Value = contractID;
                    spParams[3].Value = rowVersion;

                    try {
                        SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);
                    }
                    catch (SqlException sqlEx) {

                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            throw (sqlEx);
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 44
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);
            }
        }
Exemplo n.º 45
0
        public static void OverPlantSave(int overPlantID, int memberID, int cropYear, int overPlantUsed, string overPlantAccept, bool isFormReceived, 
            bool isOverridePct, decimal opMemberPct, int opFactoryNumber, string userName)
        {
            const string METHOD_NAME = "OverPlantSave";

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpOverPlantSave";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = overPlantID;
                    spParams[1].Value = memberID;
                    spParams[2].Value = cropYear;
                    spParams[3].Value = overPlantUsed;
                    spParams[4].Value = overPlantAccept;
                    spParams[5].Value = isFormReceived;
                    spParams[6].Value = isOverridePct;
                    spParams[7].Value = opMemberPct;
                    spParams[8].Value = opFactoryNumber;
                    spParams[9].Value = userName;

                    try {
                        SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);
                    }
                    catch (SqlException sqlEx) {

                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            throw (sqlEx);
                        }
                    }
                }
            }
            catch (System.Exception ex) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 46
0
        public static List<ListOverPlantMemberItem> OverPlantMemberGetInfo(int memberID, int cropYear, string userNname)
        {
            const string METHOD_NAME = "OverPlantMemberGetInfo";

            List<ListOverPlantMemberItem> state = new List<ListOverPlantMemberItem>();

            try {

                string procName = "bawpOverPlantMemberGetInfo";

                try {

                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                        if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                        System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                        spParams[0].Value = memberID;
                        spParams[1].Value = cropYear;
                        spParams[2].Value = userNname;

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                            int iOverPlantID = dr.GetOrdinal("OverPlantID");
                            int iMemberID = dr.GetOrdinal("MemberID");
                            int iShid = dr.GetOrdinal("SHID");
                            int iOverPlantAccept = dr.GetOrdinal("OverPlantAccept");
                            int iOverPlantUsed = dr.GetOrdinal("OverPlantUsed");
                            int iIsFormReceived = dr.GetOrdinal("IsFormReceived");
                            int iPatronSharesOwned = dr.GetOrdinal("PatronSharesOwned");
                            int iOverPlantPct = dr.GetOrdinal("OverPlantPct");
                            int iOverPlantPossible = dr.GetOrdinal("OverPlantPossible");
                            int iHomeFactoryNumber = dr.GetOrdinal("HomeFactoryNumber");
                            int iHomeFactoryName = dr.GetOrdinal("HomeFactoryName");
                            int iOverPlantFactoryNumber = dr.GetOrdinal("OverPlantFactoryNumber");
                            int iOverPlantFactoryName = dr.GetOrdinal("OverPlantFactoryName");
                            int iIsOverridePct = dr.GetOrdinal("IsOverridePct");
                            int iIsOverPlantAllowed = dr.GetOrdinal("IsOverPlantAllowed");

                            while (dr.Read()) {

                                state.Add(new ListOverPlantMemberItem(dr.GetInt32(iOverPlantID), dr.GetInt32(iMemberID),
                                    dr.GetString(iShid), dr.GetString(iOverPlantAccept), dr.GetInt32(iOverPlantUsed),
                                    dr.GetBoolean(iIsFormReceived), dr.GetInt32(iPatronSharesOwned), dr.GetDecimal(iOverPlantPct), dr.GetInt32(iOverPlantPossible),
                                    dr.GetString(iHomeFactoryNumber), dr.GetString(iHomeFactoryName), dr.GetString(iOverPlantFactoryNumber), dr.GetString(iOverPlantFactoryName),
                                    dr.GetBoolean(iIsOverridePct), dr.GetBoolean(iIsOverPlantAllowed)));
                            }
                        }
                    }
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        throw (sqlEx);
                    }
                }
            }
            catch (System.Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wscEx);
            }

            return state;
        }
Exemplo n.º 47
0
        public static SqlDataReader GetEquityPaymentExport(SqlConnection conn, int paymentCropYear, bool isPatronage, string paymentType, string paymentDate,
            ref System.Data.SqlClient.SqlParameter outParam)
        {
            const string METHOD_NAME = "GetEquityPaymentExport";
            SqlDataReader dr = null;

            try {

                if (isPatronage) {

                    string procName = "bawpPatronagePaymentExport";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = paymentCropYear;
                    spParams[1].Value = paymentType;
                    spParams[2].Value = paymentDate;
                    outParam = spParams[3];
                    SetTimeout();

                    try {
                        dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                    }
                    catch (SqlException sqlEx) {
                        if (dr != null && !dr.IsClosed) {
                            dr.Close();
                        }
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                            throw (wscEx);
                        }
                    }

                } else {

                    string procName = "bawpRetainPaymentExport";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = paymentCropYear;
                    spParams[1].Value = paymentDate;
                    outParam = spParams[2];
                    SetTimeout();

                    try {
                        dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                    }
                    catch (SqlException sqlEx) {
                        if (dr != null && !dr.IsClosed) {
                            dr.Close();
                        }
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                            throw (wscEx);
                        }
                    }

                }
            }
            catch (System.Exception e) {

                if (dr != null && !dr.IsClosed) {
                    dr.Close();
                }
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }

            return dr;
        }
Exemplo n.º 48
0
        public static List<TransDeductionListItem> GetTransmittalDeduction2(string connStr, int cropYear, int paymentDescID, 
			int paymentDescNumber, int firstContractNumber, int lastContractNumber, bool isCumulative)
        {
            const string METHOD_NAME = "GetTransmittalDeduction2: ";

            try {

                string procName = "bawpRptTransmittalDeduction2";

                List<TransDeductionListItem> stateList = new List<TransDeductionListItem>();

                int iContractNumber = 0, iPaymentNumber = 0, iDeductionNumber = 0, iDeductionDesc = 0,
                    iPaymentDescription = 0, iAmount = 0;

                using (SqlConnection conn = new SqlConnection(connStr)) {

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = cropYear;
                    spParams[1].Value = paymentDescID;
                    spParams[2].Value = paymentDescNumber;
                    spParams[3].Value = firstContractNumber;
                    spParams[4].Value = lastContractNumber;
                    spParams[5].Value = isCumulative;

                    SetTimeout();

                    try {

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                            iContractNumber = dr.GetOrdinal("Contract_Number");
                            iPaymentNumber = dr.GetOrdinal("Payment_Number");
                            iDeductionNumber = dr.GetOrdinal("Deduction_Number");
                            iDeductionDesc = dr.GetOrdinal("Deduction_Desc");
                            iPaymentDescription = dr.GetOrdinal("Payment_Description");
                            iAmount = dr.GetOrdinal("Amount");

                            while (dr.Read()) {

                                stateList.Add(new TransDeductionListItem(
                                    dr.GetInt32(iContractNumber),
                                    dr.GetInt32(iPaymentNumber),
                                    dr.GetInt32(iDeductionNumber),
                                    dr.GetString(iDeductionDesc),
                                    dr.GetString(iPaymentDescription),
                                    dr.GetDecimal(iAmount)

                                ));
                            }
                        }

                        return stateList;
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }
        }
Exemplo n.º 49
0
        public static SqlDataReader RptContractPayeeSummary2(SqlConnection conn, int contractNumber, int cropYear)
        {
            const string METHOD_NAME = "RptContractPayeeSummary2: ";
            SqlDataReader dr = null;

            try {

                string procName = "bawpRptContractPayeeSummary2";

                if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = contractNumber;
                spParams[1].Value = cropYear;
                SetTimeout();

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (dr != null && !dr.IsClosed) {
                        dr.Close();
                    }
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {

                if (dr != null && !dr.IsClosed) {
                    dr.Close();
                }
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }

            return dr;
        }
Exemplo n.º 50
0
        public static SqlDataReader RptContractPayeeSummary1(SqlConnection conn, int cropYear, string shid)
        {
            const string METHOD_NAME = "RptContractPayeeSummary1: ";
            SqlDataReader dr = null;
            string shidList = null;
            string shidLo = null;
            string shidHi = null;

            // Configure the appropriate shid passed parameters based on the incoming
            // shid string.
            if (shid == null || shid.Length == 0) {
                WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You must enter a SHID or a list or range of SHIDs.");
                throw (warn);
            }

            try {

                BeetDataDomain.SplitShidList(shid, out shidList, out shidLo, out shidHi);

                string procName = "bawpRptContractPayeeSummary1";

                if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = cropYear;
                spParams[1].Value = shidList;
                spParams[2].Value = shidLo;
                spParams[3].Value = shidHi;
                SetTimeout();

                try {
                    dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (dr != null && !dr.IsClosed) {
                        dr.Close();
                    }
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {

                if (dr != null && !dr.IsClosed) {
                    dr.Close();
                }
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }

            return dr;
        }
Exemplo n.º 51
0
        public static List<BeetPaymentListItem> RptBeetPayBreakdown(string connStr, int shid,
			int cropYear, int calYear)
        {
            const string METHOD_NAME = "RptBeetPayBreakdown: ";

            try {

                string procName = "bawpRptBeetPayBreakdown";

                List<BeetPaymentListItem> stateList = new List<BeetPaymentListItem>();

                using (SqlConnection conn = new SqlConnection(connStr)) {

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = shid;
                    spParams[1].Value = cropYear;
                    spParams[2].Value = calYear;

                    try {

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                            int iSHID = dr.GetOrdinal("SHID"),
                            iPayeeName = dr.GetOrdinal("PayeeName"),
                            iCropYear = dr.GetOrdinal("CropYear"),
                            iCalendarYear = dr.GetOrdinal("CalendarYear"),
                            iPaymentNumber = dr.GetOrdinal("PaymentNumber"),
                            iPaymentDescription = dr.GetOrdinal("PaymentDescription"),
                            iTransmittalDate = dr.GetOrdinal("TransmittalDate"),
                            iGrossDollars = dr.GetOrdinal("GrossDollars"),
                            iPaymentAmount = dr.GetOrdinal("PaymentAmount");

                            while (dr.Read()) {

                                stateList.Add(new BeetPaymentListItem(
                                    dr.GetInt32(iSHID),
                                    dr.GetString(iPayeeName),
                                    dr.GetInt32(iCropYear),
                                    dr.GetInt32(iCalendarYear),
                                    dr.GetInt32(iPaymentNumber),
                                    dr.GetString(iPaymentDescription),
                                    dr.GetDateTime(iTransmittalDate),
                                    dr.GetDecimal(iGrossDollars),
                                    dr.GetDecimal(iPaymentAmount)

                                ));
                            }
                        }

                        return stateList;
                    }
                    catch (SqlException sqlEx) {
                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }
        }
Exemplo n.º 52
0
        public static void PostCalculatePayment(SqlConnection conn, int factoryID, int paymentNumber, int cropYear, string userName)
        {
            const string METHOD_NAME = "PostCalculatePayment: ";

            try {

                string procName = "s70pay_PostCalculatePayment";

                if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                System.Data.SqlClient.SqlParameter[] spParams = SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = factoryID;
                spParams[1].Value = paymentNumber;
                spParams[2].Value = cropYear;
                spParams[3].Value = userName;
                SetTimeout();

                try {
                    SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }
        }
Exemplo n.º 53
0
        public static void PaymentDescriptionSave(int payDescriptionID,
            int payNumber, int cropYear, string payDesc, bool required, bool finished,
            string transmittalDate, string UserName)
        {
            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpPaymentSaveDesc";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[1].Value = payDescriptionID;
                    spParams[2].Value = payNumber;
                    spParams[3].Value = cropYear;
                    spParams[4].Value = payDesc;
                    spParams[5].Value = required;
                    spParams[6].Value = finished;
                    if (transmittalDate != null && transmittalDate.Length > 0) {
                        spParams[7].Value = DateTime.Parse(transmittalDate);
                    } else {
                        spParams[7].Value = DBNull.Value;
                    }
                    spParams[8].Value = UserName;
                    SetTimeout();

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {

                            if (tran != null) {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            } else {
                                string errMsg = MOD_NAME + "PaymentDescriptionSave";
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + "PaymentDescriptionSave";
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 54
0
        public static void PaymentDescriptionContractSave(int pdecnt_description_contract_id,
			int pdecnt_description_id, int pdecnt_factory_id, int pdecnt_station_id,
			int pdecnt_contract_id, int pdecnt_icrop_year, decimal pdecnt_excess_beet_pct,
			string UserName, string pdecnt_rowversion)
        {
            const string METHOD_NAME = "PaymentDescriptionContractSave";

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpPdeCntSave";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = pdecnt_description_contract_id;
                    spParams[1].Value = pdecnt_description_id;
                    spParams[2].Value = pdecnt_factory_id;
                    spParams[3].Value = pdecnt_station_id;
                    spParams[4].Value = pdecnt_contract_id;
                    spParams[5].Value = pdecnt_icrop_year;
                    spParams[6].Value = pdecnt_excess_beet_pct;
                    spParams[7].Value = UserName;
                    if (pdecnt_rowversion == "") {
                        spParams[8].Value = DBNull.Value;
                    } else {
                        spParams[8].Value = pdecnt_rowversion;
                    }

                    using (SqlTransaction tran = conn.BeginTransaction()) {
                        try {
                            SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, procName, spParams);
                            tran.Commit();
                        }
                        catch (SqlException sqlEx) {

                            if (tran != null) {
                                tran.Rollback();
                            }
                            if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                                WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                                throw (wscWarn);
                            } else {
                                string errMsg = MOD_NAME + METHOD_NAME;
                                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                                throw (wscEx);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e) {
                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }
Exemplo n.º 55
0
        public static List<TransmittalDeliveryItem> GetTransmittalDelivery(int cropYear, int contractNumber, int paymentNumber, string fromDate, string toDate)
        {
            const string METHOD_NAME = "GetTransmittalDelivery: ";

            List<TransmittalDeliveryItem> stateList = new List<TransmittalDeliveryItem>();
            try {

                string procName = "bawpRptTransmittalDelivery";

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = cropYear;
                    spParams[1].Value = contractNumber;
                    spParams[2].Value = paymentNumber;
                    if (fromDate != null) {
                        spParams[3].Value = DateTime.Parse(fromDate);
                    } else {
                        spParams[3].Value = DBNull.Value;
                    }
                    if (toDate != null) {
                        spParams[4].Value = DateTime.Parse(toDate);
                    } else {
                        spParams[4].Value = DBNull.Value;
                    }

                    SetTimeout();

                    try {

                        using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                            int iDelivery_Date = dr.GetOrdinal("Delivery_Date"),
                            iSLM_Pct = dr.GetOrdinal("SLM_Pct"),
                            iFirst_Net_Pounds = dr.GetOrdinal("First_Net_Pounds"),
                            iFinal_Net_Pounds = dr.GetOrdinal("Final_Net_Pounds"),
                            iSugar_Content = dr.GetOrdinal("Sugar_Content"),
                            iTare = dr.GetOrdinal("Tare"),
                            iTares = dr.GetOrdinal("Tares"),
                            iLoads = dr.GetOrdinal("Loads");

                            while (dr.Read()) {

                                stateList.Add(
                                    new TransmittalDeliveryItem(
                                        dr.GetDateTime(iDelivery_Date),
                                        dr.GetDecimal(iSLM_Pct),
                                        dr.GetInt32(iFirst_Net_Pounds),
                                        dr.GetInt32(iFinal_Net_Pounds),
                                        dr.GetDecimal(iSugar_Content),
                                        dr.GetDecimal(iTare),
                                        dr.GetInt32(iTares),
                                        dr.GetInt32(iLoads)
                                    )
                                );
                            }
                        }
                    }
                    catch (SqlException sqlEx) {

                        if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                            WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                            throw (wscWarn);
                        } else {
                            WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                            throw (wscEx);
                        }
                    }
                }
            }
            catch (System.Exception e) {

                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }

            return stateList;
        }
Exemplo n.º 56
0
        public static string ReportPackager(
            int cropYear, string statementDate, string shid, string fromShid, string toShid, int paymentDescID,
            bool isCumulative, string footerText, string fileName, string logoUrl, string pdfTempfolder)
        {
            const string METHOD_NAME = "rptPaymentSummary.ReportPackager: ";
            DirectoryInfo pdfDir = null;
            FileInfo[] pdfFiles = null;
            string filePath = "";

            try {

                pdfDir = new DirectoryInfo(pdfTempfolder);

                // Build the output file name by getting a list of all PDF files
                // that begin with this session ID: use this as a name incrementer.
                pdfFiles = pdfDir.GetFiles(fileName + "*.pdf");
                fileName += "_" + Convert.ToString(pdfFiles.Length + 1) + ".pdf";

                filePath = pdfDir.FullName + @"\" + fileName;

                try {

                    // Because this report is built by data in one data set driving the selection of
                    // data in a dependent dataset, all the data retrival has to be driven down to the
                    // ReportBuilder.  This is not the typical situation.
                    if (shid.Length == 0 && fromShid.Length == 0 && toShid.Length == 0) {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter SHID information before requesting a report.");
                        throw (warn);
                    } else {

                        if (shid.Length > 0 && (fromShid.Length > 0 || toShid.Length > 0)) {
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a single SHID or a SHID range, but not both.");
                            throw (warn);
                        }

                        List<SHPaySumListItem> stateList = WSCPayment.GetPaymentSummary(ConfigurationManager.ConnectionStrings["BeetConn"].ToString(),
                            cropYear, shid, fromShid, toShid, paymentDescID, isCumulative);

                        if (stateList.Count != 0) {
                            using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write)) {
                                ReportBuilder(stateList, cropYear, statementDate, shid, fromShid, toShid, paymentDescID, isCumulative, footerText, logoUrl, fs);
                            }
                        } else {
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("SHID does not have the required transmittal records or rollup records to create a Payment Summary report.");
                            throw (warn);
                        }
                    }
                }
                catch (System.Exception ex) {
                    string errMsg = "cropYear: " + cropYear.ToString() + "; " +
                        "SHID: " + shid + "; " +
                        "From SHID: " + fromShid + "; " +
                        "To SHID: " + toShid + "; " +
                        "filePath: " + filePath + "; " +
                        "Payment Desc ID: " + paymentDescID.ToString();

                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex);
                    throw (wscEx);
                }

                return filePath;
            }
            catch (System.Exception ex) {
                string errMsg = "cropYear: " + cropYear.ToString() + "; " +
                    "SHID: " + shid + "; " +
                    "From SHID: " + fromShid + "; " +
                    "To SHID: " + toShid + "; " +
                    "Payment Desc ID: " + paymentDescID.ToString();

                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex);
                throw (wscEx);
            }
        }
Exemplo n.º 57
0
        private static void ReportBuilder(List<SHPaySumListItem> stateList, int cropYear, string statementDate, string shid,
            string fromShid, string toShid, int paymentDescID, bool isCumulative, string rptFooter, string logoUrl, FileStream fs)
        {
            const string METHOD_NAME = "rptPaymentSummary.ReportBuilder: ";
            Document document = null;
            PdfWriter writer = null;
            PdfPTable table = null;
            PaymentSummaryEvent pgEvent = null;
            iTextSharp.text.Image imgLogo = null;

            decimal totalTons = 0;
            decimal totalEHPrem = 0;
            decimal totalGross = 0;
            decimal totalDeductions = 0;
            decimal totalNet = 0;
            decimal totalGrowerNet = 0;
            decimal totalLandownerNet = 0;
            decimal checkAmount = 0;
            int resetFlag = 0;
            int checkSequence = 0;
            int payeeNumber = 0;

            string rptTitle = "Western Sugar Cooperative Payment Summary";

            Font headerFont = FontFactory.GetFont("HELVETICA", 8F, Font.NORMAL);
            Font normalFont = FontFactory.GetFont("HELVETICA", 8F, Font.NORMAL);
            Font labelFont = FontFactory.GetFont("HELVETICA", 8F, Font.BOLD);

            try {

                int firstContractNumber = stateList.Min(c => c.i_ContractNumber);
                int lastContractNumber = stateList.Max(c => c.i_ContractNumber);

                List<TransDeductionListItem> deductionList = WSCPayment.GetTransmittalDeduction2(ConfigurationManager.ConnectionStrings["BeetConn"].ToString(),
                    cropYear, paymentDescID, 0, firstContractNumber, lastContractNumber, isCumulative);

                foreach (SHPaySumListItem item in stateList) {

                    if (document == null) {

                        // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!!
                        //  ***  US LETTER: 612 X 792  ***
                        //document = new Document(iTextSharp.text.PageSize.LETTER, 36, 36, 54, 72);
                        document = new Document(PortraitPageSize.PgPageSize, PortraitPageSize.PgLeftMargin,
                            PortraitPageSize.PgRightMargin, PortraitPageSize.PgTopMargin, PortraitPageSize.PgBottomMargin);

                        // we create a writer that listens to the document
                        // and directs a PDF-stream to a file
                        writer = PdfWriter.GetInstance(document, fs);

                        imgLogo = PdfReports.GetImage(logoUrl, 127, 50, iTextSharp.text.Element.ALIGN_CENTER);

                        // Attach my override event handler(s)
                        checkSequence = item.i_CheckSequence;
                        pgEvent = new PaymentSummaryEvent();
                        pgEvent.FillEvent(item, cropYear, statementDate, resetFlag, rptTitle, imgLogo);

                        writer.PageEvent = pgEvent;
                        pgEvent.HeaderNameList = _detailSectionHdrNames;
                        pgEvent.HeaderTableLayout = _primaryTableLayout;

                        // Open the document
                        document.Open();
                        pgEvent.HeaderTableLayout = null;

                        table = PdfReports.CreateTable(_primaryTableLayout, 1);
                        checkAmount = item.d_checkAmount;
                        payeeNumber = item.i_Payee_Number;

                    } else {

                        if (checkSequence != item.i_CheckSequence) {

                            AddTotals(ref writer, ref document, ref table, labelFont, normalFont, totalTons,
                                totalEHPrem, totalGross, totalDeductions, totalNet, checkAmount,
                                payeeNumber, totalGrowerNet, totalLandownerNet, pgEvent);
                            AddFooter(ref writer, ref document, normalFont, rptFooter, pgEvent);

                            // Clear totals values
                            totalTons = 0;
                            totalEHPrem = 0;
                            totalGross = 0;
                            totalDeductions = 0;
                            totalNet = 0;
                            totalGrowerNet = 0;
                            totalLandownerNet = 0;

                            checkSequence = item.i_CheckSequence;

                            // NEW CHECK
                            pgEvent.FillEvent(item, cropYear, statementDate, resetFlag, rptTitle, imgLogo);
                            pgEvent.HeaderTableLayout = _primaryTableLayout;

                            document.NewPage();
                            pgEvent.HeaderTableLayout = null;

                            table = PdfReports.CreateTable(_primaryTableLayout, 1);
                            checkAmount = item.d_checkAmount;
                            payeeNumber = item.i_Payee_Number;

                            //AddDetailSectionHdr(ref table, labelFont, normalFont);
                        }
                    }

                    // =======================================================
                    // Contract Number Line
                    // =======================================================
                    PdfReports.AddText2Table(table, "Contract", labelFont, "left");
                    PdfReports.AddText2Table(table, item.i_ContractNumber.ToString(), labelFont, "center");
                    PdfReports.AddText2Table(table, " ", normalFont);
                    PdfReports.AddText2Table(table, item.d_Avg_SLM.ToString("N4"), normalFont, "right");

                    PdfReports.AddText2Table(table, " ", normalFont, 3);
                    PdfReports.AddText2Table(table, item.d_EH_Bonus.ToString("N2"), normalFont, "right", 2);
                    totalEHPrem += item.d_EH_Bonus;
                    PdfReports.AddText2Table(table, " ", normalFont, 4);

                    // =======================================================
                    // Station Name Line
                    // =======================================================
                    PdfReports.AddText2Table(table, "Station", normalFont);
                    PdfReports.AddText2Table(table, item.s_Station_Name, normalFont, "center");
                    PdfReports.AddText2Table(table, "EH", normalFont, "center");
                    PdfReports.AddText2Table(table, item.d_EH_SLM.ToString("N4"), normalFont, "right");
                    PdfReports.AddText2Table(table, item.d_EH_Sugar.ToString("N2"), normalFont, "right");
                    PdfReports.AddText2Table(table, item.d_EH_Paid.ToString("N3"), normalFont, "right");
                    PdfReports.AddText2Table(table, item.d_EH_Price.ToString("N3"), normalFont, "right");

                    PdfReports.AddText2Table(table, (item.d_EH_Tons - item.d_EH_tons_moved).ToString("N4"), normalFont, "right");
                    totalTons += item.d_EH_Tons;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    PdfReports.AddText2Table(table, (item.d_EH_Gross_Pay - item.d_EH_amt_moved).ToString("N2"), normalFont, "right");
                    totalGross += item.d_EH_Gross_Pay;

                    PdfReports.AddText2Table(table, " ", normalFont, 3);

                    // =======================================================
                    // Landowner Name Line
                    // =======================================================
                    PdfReports.AddText2Table(table, "LO", normalFont);
                    PdfReports.AddText2Table(table, item.s_LOName, normalFont, "center");
                    PdfReports.AddText2Table(table, "RH", normalFont, "center");

                    PdfReports.AddText2Table(table, item.d_RH_SLM.ToString("N4"), normalFont, "right");
                    PdfReports.AddText2Table(table, item.d_RH_Sugar.ToString("N2"), normalFont, "right");
                    PdfReports.AddText2Table(table, item.d_RH_Paid.ToString("N3"), normalFont, "right");
                    PdfReports.AddText2Table(table, item.d_RH_Price.ToString("N3"), normalFont, "right");

                    PdfReports.AddText2Table(table, (item.d_RH_Tons - item.d_RH_tons_moved).ToString("N4"), normalFont, "right");
                    totalTons += item.d_RH_Tons;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    PdfReports.AddText2Table(table, (item.d_RH_Gross_Pay - item.d_RH_amt_moved).ToString("N2"), normalFont, "right");
                    totalGross += item.d_RH_Gross_Pay;

                    PdfReports.AddText2Table(table, item.d_Deduct_Total.ToString("N2"), normalFont, "right");
                    totalDeductions += item.d_Deduct_Total;

                    PdfReports.AddText2Table(table, (item.d_Total_Net - item.d_EH_amt_moved - item.d_RH_amt_moved).ToString("N2"), normalFont, "right");
                    totalNet += item.d_Total_Net;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    // =======================================================
                    // Reduced for Excess Beets
                    // =======================================================
                    // Reduced Early Harvest
                    PdfReports.AddText2Table(table, "Reduced Early Harvest Excess Beets", normalFont, 3);
                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont, "right");

                    PdfReports.AddText2Table(table, item.d_EH_tons_moved.ToString("#,#.0000;(#,#.0000)"), normalFont, "right");
                    //totalTons += item.d_RH_Tons;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    PdfReports.AddText2Table(table, item.d_EH_amt_moved.ToString("#,#.00;(#,#.00)"), normalFont, "right");
                    //totalGross += item.d_RH_Gross_Pay;

                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    //totalDeductions += item.d_Deduct_Total;

                    PdfReports.AddText2Table(table, item.d_EH_amt_moved.ToString("#,#.00;(#,#.00)"), normalFont, "right");
                    //totalNet += item.d_Total_Net;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    // Reduced Regular Harvest
                    PdfReports.AddText2Table(table, "Reduced Regular Harvest  Excess Beets", normalFont, 3);
                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont, "right");

                    PdfReports.AddText2Table(table, item.d_RH_tons_moved.ToString("#,#.0000;(#,#.0000)"), normalFont, "right");
                    //totalTons += item.d_RH_Tons;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    PdfReports.AddText2Table(table, item.d_RH_amt_moved.ToString("#,#.00;(#,#.00)"), normalFont, "right");
                    //totalGross += item.d_RH_Gross_Pay;

                    PdfReports.AddText2Table(table, " ", normalFont, "right");
                    //totalDeductions += item.d_Deduct_Total;

                    PdfReports.AddText2Table(table, item.d_RH_amt_moved.ToString("#,#.00;(#,#.00)"), normalFont, "right");
                    //totalNet += item.d_Total_Net;

                    PdfReports.AddText2Table(table, " ", normalFont);

                    // =======================================================
                    // Grower / Landowner NET Split
                    // =======================================================
                    PdfReports.AddText2Table(table, " ", normalFont, 9);
                    PdfReports.AddText2Table(table, "Grower Net", labelFont, 2);
                    totalGrowerNet += item.d_groAmount;
                    PdfReports.AddText2Table(table, item.d_groAmount.ToString("N2"), normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont);

                    PdfReports.AddText2Table(table, " ", normalFont, 9);
                    PdfReports.AddText2Table(table, "Landowner Net", labelFont, 2);
                    totalLandownerNet += item.d_ldoAmount;
                    PdfReports.AddText2Table(table, item.d_ldoAmount.ToString("N2"), normalFont, "right");
                    PdfReports.AddText2Table(table, " ", normalFont);

                    // BLANK LINE
                    PdfReports.AddText2Table(table, " ", normalFont, 13);

                    pgEvent.HeaderTableLayout = _primaryTableLayout;
                    PdfReports.AddTableNoSplit(document, pgEvent, table);
                    pgEvent.HeaderTableLayout = null;

                    //================================================================
                    // Add Deduction information
                    //================================================================

                    table = PdfReports.CreateTable(_primaryTableLayout, 1);

                    PdfReports.AddText2Table(table, " ", labelFont, 4);
                    PdfReports.AddText2Table(table, "Deduction", labelFont, "left", 4);
                    PdfReports.AddText2Table(table, "Payment", labelFont, "left", 2);
                    PdfReports.AddText2Table(table, "Amount", labelFont, "center");
                    PdfReports.AddText2Table(table, " ", labelFont, 2);

                    var contractDeductions = from deduction in deductionList
                                            where deduction.Contract_Number == item.i_ContractNumber
                                            && deduction.Payment_Number <= item.i_PaymentNumber
                                            orderby deduction.Payment_Number, deduction.Deduction_Number
                                            select deduction;

                    foreach(TransDeductionListItem dedItem in contractDeductions) {

                        if (dedItem.Amount != 0) {
                            PdfReports.AddText2Table(table, " ", labelFont, 4);
                            PdfReports.AddText2Table(table, dedItem.Deduction_Desc, normalFont, "left", 4);
                            PdfReports.AddText2Table(table, dedItem.Payment_Description, normalFont, "left", 2);
                            PdfReports.AddText2Table(table, dedItem.Amount.ToString("$#,##0.00"), normalFont, "right");
                            PdfReports.AddText2Table(table, " ", labelFont, 2);
                        }
                    }

                    PdfReports.AddText2Table(table, " ", normalFont, 13);
                }

                // BLANK LINE
                PdfReports.AddText2Table(table, " ", normalFont, 13);
                PdfReports.AddTableNoSplit(document, pgEvent, table);

                table = PdfReports.CreateTable(_primaryTableLayout, 1);

                // ======================================================
                // Close document
                // ======================================================
                if (document != null) {

                    table = PdfReports.CreateTable(_primaryTableLayout, 1);

                    AddTotals(ref writer, ref document, ref table, labelFont, normalFont, totalTons,
                        totalEHPrem, totalGross, totalDeductions, totalNet, checkAmount,
                        payeeNumber, totalGrowerNet, totalLandownerNet, pgEvent);

                    AddFooter(ref writer, ref document, normalFont, rptFooter, pgEvent);

                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                    document = null;
                }
                if (writer == null) {
                    // Warn that we have no data.
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                    throw (warn);
                }
            }
            catch (Exception ex) {
                string errMsg = "document is null: " + (document == null).ToString() + "; " +
                    "writer is null: " + (writer == null).ToString();
                WSCIEMP.Common.CException wscex = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex);
                throw (wscex);
            }
            finally {

                if (document != null) {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                }
                if (writer != null) {
                    writer.Close();
                }
            }
        }
Exemplo n.º 58
0
        public static void CalculatePayment(SqlConnection conn,
            Decimal trialSugarContent, Decimal trialSLMPct, Decimal trialNetReturn, int cropYear,
            ref Decimal qcBeetPaymentPerTon, ref Decimal oldNorthBeetPaymentPerTon,
            ref Decimal oldSouthBeetPaymentPerTon)
        {
            const string METHOD_NAME = "CalculatePayment: ";

            try {

                string procName = "bawpPaymentCalculator";

                if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                System.Data.SqlClient.SqlParameter[] spParams =
                    SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                spParams[0].Value = trialSugarContent;
                spParams[1].Value = trialSLMPct;
                spParams[2].Value = trialNetReturn;
                spParams[3].Value = cropYear;
                SetTimeout();

                try {

                    SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, procName, spParams);

                    qcBeetPaymentPerTon = Convert.ToDecimal(spParams[4].Value);
                    oldNorthBeetPaymentPerTon = Convert.ToDecimal(spParams[5].Value);
                    oldSouthBeetPaymentPerTon = Convert.ToDecimal(spParams[6].Value);
                }
                catch (SqlException sqlEx) {
                    if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                        WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                        throw (wscWarn);
                    } else {
                        WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, sqlEx);
                        throw (wscEx);
                    }
                }
            }
            catch (System.Exception e) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, e);
                throw (wscEx);
            }
        }
Exemplo n.º 59
0
        public static void ReportBuilder(SqlDataReader dr, int cropYear, DateTime letterDate, DateTime deadlineDate, string logoUrl, System.IO.FileStream fs)
        {
            const string METHOD_NAME = "ReportBuilder";
            const float primaryLeading = 13.5F;
            const float primaryLeftIndent = 20F;
            string strLetterDate = letterDate.ToString("MMMM dd, yyyy");
            string strDeadlineDate = deadlineDate.ToString("MMMM dd, yyyy");
            string LdoBusinessName = "";
            string tmpStr = "";
            string tmpStr2 = "";

            Document document = null;
            PdfWriter writer = null;
            LandownerLetterEvent pgEvent = null;
            ColumnText ct = null;
            iTextSharp.text.Image imgLogo = null;

            try {

                while (dr.Read()) {

                    LdoBusinessName = dr["LdoBusinessName"].ToString();
                    string LdoAddressLine1 = dr["LdoAddressLine1"].ToString();
                    string LdoAddressLine2 = dr["LdoAddressLine2"].ToString();
                    string LdoCityStateZip = dr["LdoCityStateZip"].ToString();

                    if (document == null) {

                        // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!!
                        //  ***  US LETTER: 612 X 792  ***
                        document = new Document(PortraitPageSize.PgPageSize, PortraitPageSize.PgLeftMargin,
                            PortraitPageSize.PgRightMargin, PortraitPageSize.PgTopMargin, PortraitPageSize.PgBottomMargin);

                        imgLogo = PdfReports.GetImage(logoUrl, 127, 50, iTextSharp.text.Element.ALIGN_CENTER);

                        // we create a writer that listens to the document
                        // and directs a PDF-stream to a file
                        writer = PdfWriter.GetInstance(document, fs);

                        // Attach my override event handler(s)
                        pgEvent = new LandownerLetterEvent();
                        pgEvent.FillEvent(imgLogo, strLetterDate, LdoBusinessName, LdoAddressLine1, LdoAddressLine2, LdoCityStateZip);
                        writer.PageEvent = pgEvent;

                        // Open the document
                        document.Open();

                    } else {
                        pgEvent.FillEvent(imgLogo, strLetterDate, LdoBusinessName, LdoAddressLine1, LdoAddressLine2, LdoCityStateZip);
                        document.NewPage();
                    }

                    ct = pgEvent.GetColumnObject();

                    Paragraph p = new Paragraph(primaryLeading, "Your tenant, " + dr["GroBusinessName"].ToString() +
                    ", has indicated that the proceeds for sugar beets grown on your land in\n" +
                    cropYear.ToString() + " are to be split and you will be receiving " + dr.GetDecimal(dr.GetOrdinal("LdoSplitPercent")).ToString("##.0##") +
                    "% of the proceeds. Since Western Sugar Cooperative no\n" +
                    "longer requires signatures for the second payees, this letter has been sent for your verification.\n\n", _normalFont);

                    ct.AddElement(p);

                    p = new Paragraph(new Phrase(primaryLeading, "Your check will be made payable as follows:", _normalFont));
                    ct.AddElement(p);
                    p = new Paragraph(primaryLeading, dr["ldoPayeeDescription"].ToString(), _normalFont);
                    p.IndentationLeft = primaryLeftIndent;
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "If you have a lien on the beets, the lien holder’s name should be included above.\n\n" +
                    "In addition, the following options were selected by your tenant.", _normalFont);
                    ct.AddElement(p);

                    decimal ldoChemPct = dr.GetDecimal(dr.GetOrdinal("LdoChemicalSplitPct"));
                    if (dr.GetBoolean(dr.GetOrdinal("IsSplitChemical")) && ldoChemPct != 0) {
                        tmpStr = ldoChemPct.ToString("##.0##") + "%";
                    } else {
                        tmpStr = "No";
                    }

                    decimal ldoRetainPct = dr.GetDecimal(dr.GetOrdinal("LdoSplitPercent"));
                    if (dr.GetBoolean(dr.GetOrdinal("IsSplitRetain")) && ldoRetainPct != 0) {
                        tmpStr2 = ldoRetainPct.ToString("##.0##") + "% of the";
                    } else {
                        tmpStr2 = "No";
                    }

                    p = new Paragraph(primaryLeading, tmpStr2 + " Unit Retains on this contract will be deducted from your proceeds.\n" +
                    tmpStr + " seed & chemical receivables charged to this contract will be deducted from your proceeds.", _normalFont);
                    p.IndentationLeft = primaryLeftIndent;
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "If the above information is correct, no response is needed.\n\n", _normalFont);
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "If any of the above information is not correct, please contact your tenant’s agriculturist, " +
                    dr["AgriculturistName"].ToString() +
                    " at\n" + WSCIEMP.Common.CodeLib.FormatPhoneNumber2Display(dr["AgriculturistPhone"].ToString()) +
                    " by " + strDeadlineDate + ", or mail the corrections to:\n\n", _normalFont);
                    ct.AddElement(p);

                    p = new Paragraph(12F, "Western Sugar Cooperative\n" +
                    "Attn: Marty Smith\n" +
                    "1221 8th Avenue Unit E\n" +
                    "Greeley, CO  80631\n\n", _normalFont);
                    p.IndentationLeft = primaryLeftIndent;
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "Sincerely,\n\n" +
                    "Marty Smith\n" +
                    "Beet Accounting Manager\n\n" +
                    "Ref: " + dr["ContractNo"].ToString(), _normalFont);
                    ct.AddElement(p);

                    ct.Go(false);

                }
                // ======================================================
                // Close document
                // ======================================================
                if (document != null) {

                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                    document = null;
                }
                if (writer == null || String.IsNullOrEmpty(LdoBusinessName)) {
                    // Warn that we have no data.
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                    throw (warn);
                }
            }
            catch (Exception ex) {
                string errMsg = "document is null: " + (document == null).ToString() + "; " +
                    "writer is null: " + (writer == null).ToString();
                WSCIEMP.Common.CException wscex = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME + errMsg, ex);
                throw (wscex);
            }
            finally {

                if (document != null) {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                }
                if (writer != null) {
                    writer.Close();
                }
            }
        }
Exemplo n.º 60
0
        public static List<List1099ExportItem> GetBeet1099Export(int calendarYear)
        {
            const string METHOD_NAME = "GetBeet1099Export";
            List<List1099ExportItem> state = new List<List1099ExportItem>();

            try {

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {

                    string procName = "bawpPayment1099Export";

                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    System.Data.SqlClient.SqlParameter[] spParams =
                        SqlHelperParameterCache.GetSpParameterSet(conn, procName, false);

                    spParams[0].Value = calendarYear;

                    int iSHID = 0, iTaxID = 0, iBusinessName = 0, iAddress1 = 0, iAddress2 = 0, iCity = 0, iState = 0, iZip = 0, iDollars = 0;
                    using (SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, procName, spParams)) {

                        while (dr.Read()) {

                            if (iSHID == 0) {

                                iSHID = dr.GetOrdinal("cShid");
                                iTaxID = dr.GetOrdinal("cTaxID");
                                iBusinessName = dr.GetOrdinal("cBusName");
                                iAddress1 = dr.GetOrdinal("cAddress1");
                                iAddress2 = dr.GetOrdinal("cAddress2");
                                iCity = dr.GetOrdinal("cCity");
                                iState = dr.GetOrdinal("cState");
                                iZip = dr.GetOrdinal("cZip");
                                iDollars = dr.GetOrdinal("cDollars");
                            }
                            state.Add(new List1099ExportItem(dr.GetString(iSHID), dr.GetString(iTaxID), dr.GetString(iBusinessName),
                                dr.GetString(iAddress1), dr.GetString(iAddress2), dr.GetString(iCity), dr.GetString(iState), dr.GetString(iZip), dr.GetString(iDollars)));
                        }
                    }
                }

                return state;
            }
            catch (SqlException sqlEx) {

                if (sqlEx.Number == Convert.ToInt32(WSCIEMP.Common.CException.KnownError.DataWarning)) {
                    WSCIEMP.Common.CWarning wscWarn = new WSCIEMP.Common.CWarning(sqlEx.Message, sqlEx);
                    throw (wscWarn);
                } else {
                    string errMsg = MOD_NAME + METHOD_NAME;
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, sqlEx);
                    throw (wscEx);
                }
            }
            catch (System.Exception e) {

                string errMsg = MOD_NAME + METHOD_NAME;
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, e);
                throw (wscEx);
            }
        }