Exemple #1
0
        protected void ctlDetailGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("DetailEdit"))
            {
                int  rowIndex  = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                long RateId    = UIHelper.ParseLong(ctlDetailGrid.DataKeys[rowIndex].Value.ToString());
                long ProfileId = UIHelper.ParseLong(foreignPerdiemRateProfileCode2.Value);
                ctlForeignPerdiemRateProfileDetailEditor.Initialize(FlagEnum.EditFlag, RateId, ProfileId);
                ctlForeignPerdiemRateProfileDetailEditor.ShowPopUp();
                ctlUpdatePanelDetailGrid.Update();
            }
            if (e.CommandName.Equals("DetailDelete"))
            {
                try
                {
                    int           rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    long          detailId = UIHelper.ParseLong(ctlDetailGrid.DataKeys[rowIndex].Value.ToString());
                    FnPerdiemRate fp       = ScgeAccountingQueryProvider.FnPerdiemRateQuery.FindByIdentity(detailId);
                    FnPerdiemRateService.DeleteFnPerdiemRate(fp);
                }
                catch (Exception ex)
                {
                    if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                                "alert('This data is now in use.');", true);

                        BindDetailGrid(UIHelper.ParseLong(foreignPerdiemRateProfileCode2.Value));
                        ctlUpdatePanelDetailGrid.Update();
                    }
                }
                BindDetailGrid(UIHelper.ParseLong(foreignPerdiemRateProfileCode2.Value));
                ctlUpdatePanelDetailGrid.Update();
            }
        }
        protected void ctlAdd_Click(object sender, ImageClickEventArgs e)
        {
            FnPerdiemRate fp;

            try
            {
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    fp = ScgeAccountingQueryProvider.FnPerdiemRateQuery.FindByIdentity(RATEID);
                }
                else
                {
                    fp = new FnPerdiemRate();
                }

                fp.PerdiemProfileID = PPFID;
                //    fp.PerdiemRateID = RATEID;
                fp.PersonalLevel                 = ctlPersonalLevelDropdown.SelectedItem.Value;
                fp.ZoneID                        = Helper.UIHelper.ParseShort(ctlZoneDropdown.SelectedItem.Value);
                fp.OfficialPerdiemRate           = Helper.UIHelper.ParseDouble(ctlOfficialRate.Text);
                fp.ExtraPerdiemRate              = Helper.UIHelper.ParseDouble(ctlExtraRate.Text);
                fp.InternationalStaffPerdiemRate = Helper.UIHelper.ParseDouble(ctlInternationalStaffRate.Text);
                fp.SCGStaffPerdiemRate           = Helper.UIHelper.ParseDouble(ctlSCGStaffRate.Text);
                fp.Active                        = ctlActive.Checked;
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    fp.UpdBy   = UserAccount.UserID;
                    fp.UpdDate = DateTime.Now.Date;
                    fp.UpdPgm  = ProgramCode;
                    FnPerdiemRateService.UpdateFnPerdiemRate(fp);
                }
                else if (Mode.Equals(FlagEnum.NewFlag))
                {
                    fp.UpdBy   = UserAccount.UserID;
                    fp.UpdDate = DateTime.Now.Date;
                    fp.UpdPgm  = ProgramCode;
                    fp.CreBy   = UserAccount.UserID;
                    fp.CreDate = DateTime.Now.Date;
                    FnPerdiemRateService.AddFnPerdiemRate(fp);
                }
                Notify_Ok(sender, e);
            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
                ctlUpdatePanel.Update();
            }
        }
        public void Initialize(string mode, long rateid, long ppfid)
        {
            Mode   = mode;
            RATEID = rateid;
            PPFID  = ppfid;
            IList <SuUserPersonalLevel> list = QueryProvider.SuUserPersonalLevelQuery.GetPLList();

            ctlPersonalLevelDropdown.DataSource     = list;
            ctlPersonalLevelDropdown.DataTextField  = "PersonalLevel";
            ctlPersonalLevelDropdown.DataValueField = "PersonalLevel";
            ctlPersonalLevelDropdown.DataBind();
            ctlPersonalLevelDropdown.Items.Insert(0, new ListItem("Please Select", string.Empty));


            IList <DbZoneResult> zoneList = SsDbQueryProvider.DbZoneQuery.FindZone(UserAccount.CurrentLanguageID);

            ctlZoneDropdown.DataSource     = zoneList;
            ctlZoneDropdown.DataTextField  = "ZoneName";
            ctlZoneDropdown.DataValueField = "ZoneID";
            ctlZoneDropdown.DataBind();
            ctlZoneDropdown.Items.Insert(0, new ListItem("Please Select", "-1"));
            if (Mode.Equals(FlagEnum.EditFlag))
            {
                FnPerdiemRate fp = ScgeAccountingQueryProvider.FnPerdiemRateQuery.FindByIdentity(RATEID);
                if (fp.PersonalLevel != null || fp.PersonalLevel != String.Empty)
                {
                    ctlPersonalLevelDropdown.SelectedValue = fp.PersonalLevel;
                }
                DbZoneResult zone = SsDbQueryProvider.DbZoneQuery.FindZoneByID(fp.ZoneID, UserAccount.CurrentLanguageID).FirstOrDefault();
                if (zone != null)
                {
                    ctlZoneDropdown.SelectedValue = zone.ZoneID.ToString();
                }

                ctlOfficialRate.Text           = fp.OfficialPerdiemRate.HasValue ? fp.OfficialPerdiemRate.Value.ToString("#,##0.00") : string.Empty;
                ctlExtraRate.Text              = fp.ExtraPerdiemRate.HasValue ? fp.ExtraPerdiemRate.Value.ToString("#,##0.00") : string.Empty;
                ctlInternationalStaffRate.Text = fp.InternationalStaffPerdiemRate.HasValue ? fp.InternationalStaffPerdiemRate.Value.ToString("#,##0.00"): string.Empty;
                ctlSCGStaffRate.Text           = fp.SCGStaffPerdiemRate.HasValue ? fp.SCGStaffPerdiemRate.Value.ToString("#,##0.00") : string.Empty;
                ctlActive.Checked              = fp.Active;
                ctlUpdatePanel.Update();
            }
            else if (Mode.Equals(FlagEnum.NewFlag))
            {
                ResetValue();
            }
        }