예제 #1
0
    protected void ReminderRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView row = (DataRowView)e.Item.DataItem;
        CheckBox    cb  = (CheckBox)e.Item.FindControl("ItemSelect");

        WebFormUtils.LoadKeys(EReminderType.db, row, cb);

        ((Label)e.Item.FindControl("ReminderTypeDesc")).Text = row["ReminderTypeDesc"].ToString();

        HROne.Common.WebUtility.WebControlsLocalization(this, e.Item.Controls);

        if (!Page.IsPostBack)
        {
            DBFilter userReminderOptionFilter = new DBFilter();
            userReminderOptionFilter.add(new Match("UserID", CurID));
            userReminderOptionFilter.add(new Match("ReminderTypeID", row["ReminderTypeID"]));

            ArrayList userReminderList = EUserReminderOption.db.select(dbConn, userReminderOptionFilter);
            if (userReminderList.Count > 0)
            {
                cb.Checked = true;
                EUserReminderOption userReminder = (EUserReminderOption)userReminderList[0];
                if (userReminder.UserReminderOptionRemindDaysBefore >= 0)
                {
                    ((TextBox)e.Item.FindControl("UserReminderOptionRemindDaysBefore")).Text = userReminder.UserReminderOptionRemindDaysBefore.ToString();
                }
                if (userReminder.UserReminderOptionRemindDaysAfter >= 0)
                {
                    ((TextBox)e.Item.FindControl("UserReminderOptionRemindDaysAfter")).Text = userReminder.UserReminderOptionRemindDaysAfter.ToString();
                }
            }
        }
    }
예제 #2
0
    protected void Save_Click(object sender, EventArgs e)
    {
        EUser c = new EUser();

        c.UserID              = CurID;
        c.UserLanguage        = cboLanguage.SelectedValue;
        c.UserIsKeepConnected = UserIsKeepConnected.Checked;
        //Hashtable values = new Hashtable();
        //binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(EUser.db, Page.Master);

        errors.clear();


        //db.validate(errors, values);


        //db.parse(values, c);


        ArrayList selectedList   = new ArrayList();
        ArrayList unselectedList = new ArrayList();

        foreach (RepeaterItem i in ReminderRepeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");

            TextBox txtReminderBefore = (TextBox)i.FindControl("UserReminderOptionRemindDaysBefore");
            TextBox txtReminderAfter  = (TextBox)i.FindControl("UserReminderOptionRemindDaysAfter");


            EReminderType o = new EReminderType();
            WebFormUtils.GetKeys(EReminderType.db, o, cb);
            if (EReminderType.db.select(dbConn, o))
            {
                if (cb.Checked)
                {
                    EUserReminderOption userReminderOption = new EUserReminderOption();
                    userReminderOption.UserID         = CurID;
                    userReminderOption.ReminderTypeID = o.ReminderTypeID;

                    int ReminderDaysBefore = 0, ReminderDaysAfter = 0;
                    if (int.TryParse(txtReminderBefore.Text, out ReminderDaysBefore) && int.TryParse(txtReminderAfter.Text, out ReminderDaysAfter))
                    {
                        userReminderOption.UserReminderOptionRemindDaysAfter  = ReminderDaysAfter;
                        userReminderOption.UserReminderOptionRemindDaysBefore = ReminderDaysBefore;
                        selectedList.Add(userReminderOption);
                    }
                    else
                    {
                        errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_REMINDER_DAYS_NOT_NUMERIC, new string[] { o.ReminderTypeDesc }));
                    }
                }
                else
                {
                    unselectedList.Add(o);
                }
            }
        }

        if (!errors.isEmpty())
        {
            //if (CurID > 0)
            //{
            //    loadObject();
            //    reminderView = loadReminderData(reminderInfo, EReminderType.db, ReminderRepeater);
            //}
            return;
        }

        foreach (EUserReminderOption o in selectedList)
        {
            DBFilter userReminderOptionFilter = new DBFilter();
            userReminderOptionFilter.add(new Match("UserID", CurID));
            userReminderOptionFilter.add(new Match("ReminderTypeID", o.ReminderTypeID));

            ArrayList list = EUserReminderOption.db.select(dbConn, userReminderOptionFilter);
            if (list.Count <= 0)
            {
                EUserReminderOption.db.insert(dbConn, o);
            }
            else
            {
                int count = 0;
                foreach (EUserReminderOption userReminderOption in list)
                {
                    if (count == 0)
                    {
                        userReminderOption.UserReminderOptionRemindDaysBefore = o.UserReminderOptionRemindDaysBefore;
                        userReminderOption.UserReminderOptionRemindDaysAfter  = o.UserReminderOptionRemindDaysAfter;
                        EUserReminderOption.db.update(dbConn, userReminderOption);
                    }
                    else
                    {
                        EUserReminderOption.db.delete(dbConn, userReminderOption);
                    }
                    count++;
                }
            }
        }

        foreach (EReminderType o in unselectedList)
        {
            DBFilter userReminderOptionFilter = new DBFilter();
            userReminderOptionFilter.add(new Match("UserID", CurID));
            userReminderOptionFilter.add(new Match("ReminderTypeID", o.ReminderTypeID));
            ArrayList userReminderOptionList = EUserReminderOption.db.select(dbConn, userReminderOptionFilter);
            foreach (EUserReminderOption userReminderOption in userReminderOptionList)
            {
                EUserReminderOption.db.delete(dbConn, userReminderOption);
            }
        }

        //WebUtils.StartFunction(Session, FUNCTION_CODE);
        EUser.db.update(dbConn, c);

        WebUtils.SetSessionLanguage(Session, WebUtils.GetCurUser(Session));
        HROne.Common.WebUtility.initLanguage(Session);

        errors.addError(HROne.Common.WebUtility.GetLocalizedString("Updated Successful"));

        //HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Default.aspx");
        //WebUtils.EndFunction(dbConn);


//        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Taxation_PaymentMapping_View.aspx?TaxFormType=" + TaxFormType.Text + "&TaxPayID=" + c.TaxPayID);
    }