Пример #1
0
        protected void ctlDelete_Click(object sender, ImageClickEventArgs e)
        {
            foreach (GridViewRow row in ctlAnnouncementGroupGrid.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
                {
                    try
                    {
                        //ctlAnnouncementGroupGrid.DeleteRow(row.RowIndex);
                        short announcementGroupId             = UIHelper.ParseShort(ctlAnnouncementGroupGrid.DataKeys[row.RowIndex].Value.ToString());
                        SuAnnouncementGroup announcementGroup = SuAnnouncementGroupService.FindProxyByIdentity(announcementGroupId);
                        SuAnnouncementGroupService.Delete(announcementGroup);
                    }
                    catch (Exception ex)
                    {
                        string exMessage = ex.Message;
                    }
                }
            }

            ctlAnnouncementGroupLangGrid.DataSource = null;
            ctlAnnouncementGroupLangGrid.DataBind();
            divDetailGridViewButton.Visible   = false;
            ctlFieldSetDetailGridView.Visible = false;
            ctlUpdPanelAnnGrpLang.Update();

            ctlAnnouncementGroupGrid.SelectedIndex = -1;
            ctlAnnouncementGroupGrid.DataCountAndBind();
            ctlUpdPanelAnnGrp.Update();
        }
Пример #2
0
        protected void ctlAnnouncementGroupGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            short announcementGroupId;

            if (e.CommandName == "EditAnnouncementGroup")
            {
                int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                announcementGroupId = UIHelper.ParseShort(ctlAnnouncementGroupGrid.DataKeys[rowIndex].Value.ToString());
                ctlAnnouncementGroupGrid.EditIndex = rowIndex;

                IList <SuAnnouncementGroup> list = new List <SuAnnouncementGroup>();
                list.Add(SuAnnouncementGroupService.FindProxyByIdentity(announcementGroupId));

                ctlAnnouncementGroupForm.DataSource = list;
                ctlAnnouncementGroupForm.ChangeMode(FormViewMode.Edit);
                ctlAnnouncementGroupGrid.DataCountAndBind();
                ctlUpdPanelAnnGrpForm.Update();
                ctlAnnouncementGroupForm.DataBind();
                ctlModalPopupExtender.Show();
            }
            if (e.CommandName == "Select")
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;

                announcementGroupId = UIHelper.ParseShort(ctlAnnouncementGroupGrid.DataKeys[rowIndex].Value.ToString());
                ctlAnnouncementGroupLangGrid.DataSource = QueryProvider.SuAnnouncementGroupLangQuery.FindAnnouncementGroupLangByAnnouncementGroupId(announcementGroupId);
                ctlAnnouncementGroupLangGrid.DataBind();
                divDetailGridViewButton.Visible   = true;
                ctlFieldSetDetailGridView.Visible = true;
                ctlAnnouncementGroupGrid.DataCountAndBind();
                ctlUpdPanelAnnGrpLang.Update();
            }
        }
Пример #3
0
        protected void ctlAnnouncementGroupForm_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            short announcementGroupId             = UIHelper.ParseShort(ctlAnnouncementGroupForm.DataKey.Value.ToString());
            SuAnnouncementGroup announcementGroup = SuAnnouncementGroupService.FindProxyByIdentity(announcementGroupId);
            string         existingFile           = announcementGroup.ImagePath;
            HttpPostedFile imageFile;

            GetSuAnnouncementGroupInfo(announcementGroup, out imageFile);

            try
            {
                if (imageFile == null)
                {
                    SuAnnouncementGroupService.UpdateAnnouncementGroup(announcementGroup);
                }
                else
                {
                    // if user input new file for announcementGroup.
                    SuAnnouncementGroupService.UpdateAnnouncementGroup(announcementGroup, imageFile);

                    // Get file path from Database table DbParameter.
                    //string filePath = "D:\\DotNetStandard\\main\\program\\NHibernate\\SCG.eAccounting.Web\\ImageFiles\\Announcement\\";
                    string filePath = ParameterServices.AnnouncementGoupUploadFilePath;
                    filePath = AppDomain.CurrentDomain.BaseDirectory + filePath.Replace("~", string.Empty).Replace("/", "\\");
                    // Check Directory Exist.
                    if (Directory.Exists(filePath))
                    {
                        // Delete if old file exist.
                        if (File.Exists(filePath + existingFile))
                        {
                            File.Delete(filePath + existingFile);
                        }

                        // Save new file to specific folder.
                        // imagePath contain FileName for each announcemntGroup.
                        imageFile.SaveAs(filePath + announcementGroup.ImagePath);
                    }
                    else
                    {
                        // Store directory does not exist then create new directory.
                        Directory.CreateDirectory(filePath);
                        imageFile.SaveAs(filePath + announcementGroup.ImagePath);
                    }
                }
            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
            }

            // Check if no validation error then changemode to default mode.
            if (ValidationErrors.IsEmpty)
            {
                ctlAnnouncementGroupForm.ChangeMode(FormViewMode.ReadOnly);
                ClosePopUp();
                ctlAnnouncementGroupGrid.DataCountAndBind();
            }
        }
Пример #4
0
        private void GetSuAnnouncementInfo(SuAnnouncement announcement)
        {
            short announcementGroupId = UIHelper.ParseShort(hdCtlLblAnnouncementGroupId.Value);

            //modify by tom 28/01/209
            //SCG.eAccounting.Web.UserControls.Calendar ctlCalEffectiveDate = ctlAnnouncementForm.FindControl("ctlCalEffectiveDate") as SCG.eAccounting.Web.UserControls.Calendar;
            //SCG.eAccounting.Web.UserControls.Calendar ctlCalLastDisplayDate = ctlAnnouncementForm.FindControl("ctlCalLastDisplayDate") as SCG.eAccounting.Web.UserControls.Calendar;
            UserControls.Calendar ctlCalEffectiveDate   = ctlAnnouncementForm.FindControl("ctlCalEffectiveDate") as UserControls.Calendar;
            UserControls.Calendar ctlCalLastDisplayDate = ctlAnnouncementForm.FindControl("ctlCalLastDisplayDate") as UserControls.Calendar;
            TextBox  ctlTxtComment = ctlAnnouncementForm.FindControl("ctlTxtComment") as TextBox;
            CheckBox ctlActive     = ctlAnnouncementForm.FindControl("ctlActive") as CheckBox;

            if (!string.IsNullOrEmpty(ctlCalEffectiveDate.DateValue))
            {
                try
                {
                    //DateTime effectiveDate = DateTime.Parse(ctlCalEffectiveDate.DateValue);
                    announcement.EffectiveDate = UIHelper.ParseDate(ctlCalEffectiveDate.DateValue).GetValueOrDefault(DateTime.MinValue);
                }
                catch (Exception)
                {
                    announcement.EffectiveDate = null;
                }
            }
            else
            {
                announcement.EffectiveDate = DateTime.MinValue;
            }

            if (!string.IsNullOrEmpty(ctlCalLastDisplayDate.DateValue))
            {
                try
                {
                    //DateTime lastDisplayDate = DateTime.Parse(ctlCalLastDisplayDate.DateValue);
                    announcement.LastDisplayDate = UIHelper.ParseDate(ctlCalLastDisplayDate.DateValue).GetValueOrDefault(DateTime.MinValue);
                }
                catch (Exception)
                {
                    announcement.LastDisplayDate = null;
                }
            }
            else
            {
                announcement.LastDisplayDate = DateTime.MinValue;
            }

            announcement.AnnouncementGroup = SuAnnouncementGroupService.FindProxyByIdentity(announcementGroupId);
            announcement.Comment           = ctlTxtComment.Text;
            announcement.Active            = ctlActive.Checked;
            announcement.UpdPgm            = ProgramCode;
            announcement.CreBy             = UserAccount.UserID;
            announcement.CreDate           = DateTime.Now;
            announcement.UpdBy             = UserAccount.UserID;
            announcement.UpdDate           = DateTime.Now;
        }