Example #1
0
        //JIRA-908 Changes by Ravi in 13/02/2019 -- Start
        protected void btnYes_Click(object sender, EventArgs e)
        {
            if (hdnOptionDeleteRowIndex.Value != "")
            {
                int rowIndex = Convert.ToInt16(hdnOptionDeleteRowIndex.Value);

                string optionPeriodCode     = ((Label)gvContOptionPeriod.Rows[rowIndex].FindControl("lblOption")).Text;
                string optionPeriodCodeCopy = ((HiddenField)gvContOptionPeriod.Rows[rowIndex].FindControl("hdnOptPeriodCodeCopy")).Value;
                string isModified           = ((HiddenField)gvContOptionPeriod.Rows[rowIndex].FindControl("hdnIsModified")).Value;


                if (optionPeriodCodeCopy == string.Empty)
                {
                    //validation - 1. deletion not allowed if option period is in participation table for the royaltor
                    //             2. warning if deleting row that has Rates set up
                    royContractOptionPeriodsBL = new RoyContractOptionPeriodsBL();
                    royContractOptionPeriodsBL.ValidateDelete(royaltorId, optionPeriodCode, out errorId);
                    royContractOptionPeriodsBL = null;
                    if (errorId == 1)
                    {
                        msgView.SetMessage("Option period is used in participation - cannot be deleted!", MessageType.Warning, PositionType.Auto);
                        return;
                    }
                    else if (errorId == 3)
                    {
                        hdnOptPrdToDelete.Value           = optionPeriodCode;
                        hdnOptPrdToDeleteIsModified.Value = isModified;
                        mpeConfirmDelete.Show();
                        return;
                    }
                    DeleteRowFromGrid(optionPeriodCode, isModified);
                }
            }
        }
Example #2
0
        private void LoadOptionPeriodData()
        {
            string royaltor;

            royContractOptionPeriodsBL = new RoyContractOptionPeriodsBL();
            DataSet optPeriodData = royContractOptionPeriodsBL.GetOptionPeriodData(royaltorId, Utilities.GetUserRoleId(Session["UserRole"].ToString().ToLower()), out royaltor, out maxOptionPeriodCode, out errorId);

            royContractOptionPeriodsBL = null;

            if (optPeriodData.Tables.Count != 0 && errorId != 2)
            {
                txtRoyaltorId.Text        = royaltor;
                txtOptionAddRow.Text      = maxOptionPeriodCode.ToString();
                hdnOptionPeriodCode.Value = maxOptionPeriodCode.ToString();
                dtUnitType    = optPeriodData.Tables[1];
                dtPriceType   = optPeriodData.Tables[2];
                dtReceiptType = optPeriodData.Tables[3];
                Session["RoyContOptPrdGridDataInitial"] = optPeriodData.Tables[0];
                Session["RoyContOptPrdGridData"]        = optPeriodData.Tables[0];
                Session["RoyContOptPrdUnitType"]        = dtUnitType;
                Session["RoyContOptPrdPriceType"]       = dtPriceType;
                Session["RoyContOptPrdReceiptType"]     = dtReceiptType;

                ddlUnitFieldAddRow.DataSource     = dtUnitType;
                ddlUnitFieldAddRow.DataTextField  = "item_text";
                ddlUnitFieldAddRow.DataValueField = "item_value";
                ddlUnitFieldAddRow.DataBind();
                ddlUnitFieldAddRow.Items.Insert(0, new ListItem("-"));

                ddlPriceFieldAddRow.DataSource     = dtPriceType;
                ddlPriceFieldAddRow.DataTextField  = "item_text";
                ddlPriceFieldAddRow.DataValueField = "item_value";
                ddlPriceFieldAddRow.DataBind();
                ddlPriceFieldAddRow.Items.Insert(0, new ListItem("-"));

                ddlReceiptFieldAddRow.DataSource     = dtReceiptType;
                ddlReceiptFieldAddRow.DataTextField  = "item_text";
                ddlReceiptFieldAddRow.DataValueField = "item_value";
                ddlReceiptFieldAddRow.DataBind();
                ddlReceiptFieldAddRow.Items.Insert(0, new ListItem("-"));

                if (optPeriodData.Tables[0].Rows.Count == 0)
                {
                    gvContOptionPeriod.DataSource    = optPeriodData.Tables[0];
                    gvContOptionPeriod.EmptyDataText = "No data found for the selected royaltor";
                    gvContOptionPeriod.DataBind();
                }
                else
                {
                    gvContOptionPeriod.DataSource = optPeriodData.Tables[0];
                    gvContOptionPeriod.DataBind();
                }
            }
            else if (optPeriodData.Tables.Count == 0 && errorId != 2)
            {
                dtEmpty = new DataTable();
                gvContOptionPeriod.DataSource    = dtEmpty;
                gvContOptionPeriod.EmptyDataText = "No data found for the selected royaltor";
                gvContOptionPeriod.DataBind();
            }
            else
            {
                ExceptionHandler("Error in loading grid data", string.Empty);
            }

            hdnGridDataChanged.Value = "N";
            hdnGridDataDeleted.Value = "N";
            ViewState["vsDeleteIds"] = null;
        }
Example #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Array         optionPeriodList = OptionPeriodList();
                List <string> deleteList       = new List <string>();
                if (ViewState["vsDeleteIds"] != null)
                {
                    deleteList = (List <string>)ViewState["vsDeleteIds"];
                }

                //check if any changes to save
                if (optionPeriodList.Length == 0 && deleteList.Count == 0)
                {
                    if (isNewRoyaltor == "N")
                    {
                        msgView.SetMessage("No changes made to save!", MessageType.Warning, PositionType.Auto);
                    }
                    else if (isNewRoyaltor == "Y")
                    {
                        if (gvContOptionPeriod.Rows.Count == 0)
                        {
                            msgView.SetMessage("Must be at least one option period!", MessageType.Warning, PositionType.Auto);
                        }
                        else
                        {
                            //WUIN-450
                            //set screen button enabled = Y
                            contractNavigationButtons.SetNewRoyButtonStatus(ContractScreens.OptionPeriod.ToString());

                            ScriptManager.RegisterStartupScript(this, typeof(Page), "NewRoySave", "RedirectOnNewRoyaltorSave(" + royaltorId + ");", true);
                        }
                    }

                    return;
                }

                //validate
                if (!Page.IsValid)
                {
                    msgView.SetMessage("Option period details not saved – invalid or missing data!", MessageType.Warning, PositionType.Auto);
                    return;
                }

                loggedUserID = WebUtility.HtmlDecode(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());
                string royaltor;
                royContractOptionPeriodsBL = new RoyContractOptionPeriodsBL();
                DataSet optPeriodData = royContractOptionPeriodsBL.SaveOptionPeriod(royaltorId, optionPeriodList, deleteList.ToArray(), loggedUserID,
                                                                                    Utilities.GetUserRoleId(Session["UserRole"].ToString().ToLower()), out royaltor, out maxOptionPeriodCode, out errorId);
                royContractOptionPeriodsBL = null;
                hdnGridDataChanged.Value   = "N";
                hdnGridDataDeleted.Value   = "N";
                ViewState["vsDeleteIds"]   = null;


                //WUIN-746 clearing sort hidden files
                hdnSortExpression.Value = string.Empty;
                hdnSortDirection.Value  = string.Empty;


                if (errorId == 1)
                {
                    msgView.SetMessage("Option periods not saved – option already exists for the royaltor!", MessageType.Warning, PositionType.Auto);
                    return;
                }

                if (errorId == 0)
                {
                    if (optPeriodData.Tables.Count != 0)
                    {
                        txtRoyaltorId.Text   = royaltor;
                        txtOptionAddRow.Text = maxOptionPeriodCode.ToString();
                        dtUnitType           = optPeriodData.Tables[1];
                        dtPriceType          = optPeriodData.Tables[2];
                        dtReceiptType        = optPeriodData.Tables[3];
                        Session["RoyContOptPrdGridDataInitial"] = optPeriodData.Tables[0];
                        Session["RoyContOptPrdGridData"]        = optPeriodData.Tables[0];
                        Session["RoyContOptPrdUnitType"]        = dtUnitType;
                        Session["RoyContOptPrdPriceType"]       = dtPriceType;
                        Session["RoyContOptPrdReceiptType"]     = dtReceiptType;

                        gvContOptionPeriod.DataSource = optPeriodData.Tables[0];
                        gvContOptionPeriod.DataBind();

                        if (optPeriodData.Tables[0].Rows.Count == 0)
                        {
                            gvContOptionPeriod.EmptyDataText = "No data found for the selected royaltor";
                        }
                        else
                        {
                            gvContOptionPeriod.EmptyDataText = string.Empty;
                        }
                    }
                    else if (optPeriodData.Tables.Count == 0)
                    {
                        dtEmpty = new DataTable();
                        gvContOptionPeriod.DataSource    = dtEmpty;
                        gvContOptionPeriod.EmptyDataText = "No data found for the selected royaltor";
                        gvContOptionPeriod.DataBind();
                    }

                    SetAddRowDefaultValues();

                    //new royaltor - redirect to Royalty rates screen
                    //existing royaltor - remain in same screen
                    if (isNewRoyaltor == "Y")
                    {
                        //WUIN-450
                        //set screen button enabled = Y
                        contractNavigationButtons.SetNewRoyButtonStatus(ContractScreens.OptionPeriod.ToString());

                        //redirect to Bank details screen
                        //Response.Redirect(@"~/Contract/RoyContractRoyRates.aspx?RoyaltorId=" + royaltorId.Split('-')[0].Trim() + "&isNewRoyaltor=Y", false);
                        //redirect in javascript so that issue of data not saved validation would be handled
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "NewRoySave", "RedirectOnNewRoyaltorSave(" + royaltorId.Split('-')[0].Trim() + ");", true);
                    }
                    else
                    {
                        msgView.SetMessage("Option periods saved", MessageType.Warning, PositionType.Auto);
                    }
                }
                else if (errorId == 2)
                {
                    ExceptionHandler("Error in saving option period data", string.Empty);
                }
                else
                {
                    ExceptionHandler("Error in saving option period data", string.Empty);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in saving option period data", ex.Message);
            }
        }