示例#1
0
        private void PopulateDropDowns()
        {
            adHocStatementBL = new AdHocStatementBL();
            DataSet dropdownListData = adHocStatementBL.GetDropDownData(out errorId);

            adHocStatementBL = null;

            if (dropdownListData.Tables.Count != 0 && errorId != 2)
            {
                //for royaltor search
                Session["AdHocStmtsRoyaltorList"] = dropdownListData.Tables[0];
            }
            else
            {
                ExceptionHandler("Error in fetching the search list values.", string.Empty);
            }
        }
示例#2
0
        private void LoadGridData(string royaltorId, string ownerCode)
        {
            dtGridData = (DataTable)Session["AdHocStmtGridData"];

            if (royaltorId != string.Empty)//populate royaltor
            {
                //validate if the selected royaltor is not present in grid
                if (dtGridData.Select("RoyaltorId='" + royaltorId + "'").Count() == 0)
                {
                    DataTable dtRoyaltors;
                    if (Session["AdHocStmtsRoyaltorList"] != null)
                    {
                        dtRoyaltors = (DataTable)Session["AdHocStmtsRoyaltorList"];
                        if (dtRoyaltors.Rows.Count > 0)
                        {
                            //validation -
                            //WUIN-890 - Do not allow Royaltor to be selected for Adhoc statement if
                            //           there is an existing ROYALTOR_ACTIVITY record with Status not = 4
                            //           there is an existing ROYALTOR_ACTIVITY record with Status = 5
                            if (dtRoyaltors.Select("royaltor_id='" + royaltorId + "' AND is_allowed='Y'").Count() == 0)
                            {
                                msgView.SetMessage("Royaltor cannot be selected for Adhoc Statement as it has a Statement not archived or already requested", MessageType.Warning, PositionType.Auto);
                                return;
                            }

                            var results = dtRoyaltors.AsEnumerable().Where(dr => dr.Field <Int32>("royaltor_id").Equals(Convert.ToInt32(royaltorId)));
                            if (results.Count() > 0)
                            {
                                foreach (DataRow dr in results)
                                {
                                    dtGridData.Rows.Add((Convert.ToString(dr["owner_data"]).Split(',')[0]), (Convert.ToString(dr["owner_data"]).Split(',')[1]),
                                                        (Convert.ToString(dr["royaltors"]).Split('-')[0].Trim()), (Convert.ToString(dr["royaltors"]).Split('-')[1].Trim()), "R");
                                }
                            }
                        }
                    }
                    BindGridData();
                    txtRoySearch.Text = string.Empty;
                }
                else
                {
                    //message
                    msgView.SetMessage("Selected royaltor is already present in the list to be added.", MessageType.Warning, PositionType.Auto);
                }

                txtOwnSearch.Text = string.Empty;
            }
            else if (ownerCode != string.Empty)//populate owner group
            {
                //validate if the selected owner group is not present in grid
                if (dtGridData.Select("OwnerCode='" + ownerCode + "' AND RoyaltorId is null").Count() == 0)
                {
                    string isAllowed;
                    //fetch list of royaltors for the owner code
                    adHocStatementBL = new AdHocStatementBL();
                    DataSet ownerGroupData = adHocStatementBL.GetOwnerGroupData(ownerCode, out isAllowed, out errorId);
                    adHocStatementBL = null;

                    //validation -
                    //WUIN-890 - Do not allow Royaltor to be selected for Adhoc statement if
                    //           there is an existing ROYALTOR_ACTIVITY record with Status not = 4
                    //           there is an existing ROYALTOR_ACTIVITY record with Status = 5
                    if (isAllowed == "N")
                    {
                        msgView.SetMessage("Owner cannot be selected for Adhoc Statement as one or more Royaltor has a Statement not archived or already requested", MessageType.Warning, PositionType.Auto);
                        return;
                    }

                    if (ownerGroupData.Tables.Count != 0 && errorId != 2)
                    {
                        DataTable dtOwnerGroup = ownerGroupData.Tables[0];
                        //append to existing grid data
                        foreach (DataRow dr in dtOwnerGroup.Rows)
                        {
                            if (dtGridData.Select("RoyaltorId='" + dr["RoyaltorId"].ToString() + "'").Count() == 0)
                            {
                                dtGridData.ImportRow(dr);
                            }
                        }

                        //bind to grid
                        BindGridData();
                        txtOwnSearch.Text = string.Empty;
                    }
                    else
                    {
                        ExceptionHandler("Error in fetching owner group data.", string.Empty);
                    }
                }
                else
                {
                    //message
                    msgView.SetMessage("Selected owner group is already present in the list to be added.", MessageType.Warning, PositionType.Auto);
                }

                txtRoySearch.Text = string.Empty;
            }
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //validate

                if (!Page.IsValid)
                {
                    return;
                }

                if (gvStatements.Rows.Count == 0)
                {
                    msgView.SetMessage("Please add a royaltor/owner group for the statement to be created.", MessageType.Warning, PositionType.Auto);
                    return;
                }

                string        royaltorId;
                string        levelFlag;
                List <string> roysToAdd = new List <string>();
                foreach (GridViewRow gvr in gvStatements.Rows)
                {
                    royaltorId = (gvr.FindControl("lblRoyaltor") as Label).Text;
                    levelFlag  = (gvr.FindControl("lblLelvelFlag") as Label).Text;
                    if (royaltorId != string.Empty)//royaltor level row
                    {
                        roysToAdd.Add(royaltorId + "," + levelFlag);
                    }
                }

                if (roysToAdd.Count > 0)
                {
                    string stmtDescription;
                    //if (txtStmtDesc.Text != string.Empty) //Commented by Pratik WUIN-220
                    //{
                    //    stmtDescription = txtStmtDesc.Text.Trim();
                    //}
                    //else
                    //{
                    //    string stmtDescStartDate = DateTime.Parse("01/" + txtStmtDescStartDate.Text.Trim()).ToString("MMM-yyyy", CultureInfo.InvariantCulture).ToUpper();
                    //    string stmtDescEndDate = DateTime.Parse("01/" + txtStmtDescEndDate.Text.Trim()).ToString("MMM-yyyy", CultureInfo.InvariantCulture).ToUpper();
                    //    stmtDescription = stmtDescStartDate + " to " + stmtDescEndDate;
                    //}

                    loggedUserID = WebUtility.HtmlDecode(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());
                    string stmtTypeCode = string.Empty;
                    adHocStatementBL = new AdHocStatementBL();
                    adHocStatementBL.SaveStatement(txtStmtDescStartDate.Text, txtStmtDescEndDate.Text, txtStmtDateStartDate.Text, txtStmtDateEndDate.Text, txtPaymentDate.Text, roysToAdd.ToArray(), loggedUserID, out stmtTypeCode, out errorId);
                    adHocStatementBL = null;

                    if (errorId == 1)
                    {
                        msgView.SetMessage("Invalid start and end months", MessageType.Warning, PositionType.Auto);
                    }
                    else if (errorId == 0)
                    {
                        //clear screen data
                        txtStmtDescStartDate.Text = string.Empty;
                        txtStmtDescEndDate.Text   = string.Empty;
                        //txtStmtDesc.Text = string.Empty;
                        txtStmtDateStartDate.Text = string.Empty;
                        txtStmtDateEndDate.Text   = string.Empty;
                        txtPaymentDate.Text       = string.Empty;
                        txtRoySearch.Text         = string.Empty;
                        txtOwnSearch.Text         = string.Empty;
                        dtGridData = (DataTable)Session["AdHocStmtGridData"];
                        dtGridData.Clear();
                        BindGridData();
                        PopulateDropDowns();

                        msgView.SetMessage("Ad Hoc Statement details generated with Statement Identifier '" + stmtTypeCode + "'. The Statement will be processed in the next scheduled run. ",
                                           MessageType.Warning, PositionType.Auto);
                    }
                    else
                    {
                        ExceptionHandler("Error in saving statement details.", string.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in saving ad hoc statement period.", ex.Message);
            }
        }