コード例 #1
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            BGCalendarModel model = new BGCalendarModel();
            int wDay = this.getWeekDay();
            bool succeed = false;
            int index = 0;
            int days = DateTime.DaysInMonth(Convert.ToInt32(this.ddlYear.SelectedValue), Convert.ToInt32(this.ddlMonth.SelectedValue));
            string wFlag = "";
            string remark = "";
            string sDate = "";
            string hFlag = "";
            string BG = this.ddlBG.SelectedValue.Trim();
            try
            {
                int i;
                DropDownList dlstWorkFlag;
                DropDownList dlstHolidayFlag;
                TextBox txt;
                for (i = 1; i < (days + 1); i++)
                {
                    sDate = this.ddlYear.SelectedValue + "/" + this.ddlMonth.SelectedValue + "/" + i.ToString();
                    DateTime workday = Convert.ToDateTime(sDate);
                    index = i + wDay;
                    dlstWorkFlag = (DropDownList)this.FindControl("ddlWorkFlag" + index.ToString());
                    wFlag = dlstWorkFlag.SelectedValue.Trim();
                    dlstHolidayFlag = (DropDownList)this.FindControl("ddlHolidayFlag" + index.ToString());
                    hFlag = dlstHolidayFlag.SelectedValue.Trim();
                    txt = (TextBox)this.FindControl("txtRemark" + index.ToString());
                    remark = txt.Text.Trim();
                    model.BgCode = this.ddlBG.SelectedValue.Trim();
                    model.WorkDay = workday;
                    model.WeekNo = this.GetWeekNo(sDate);
                    model.WeekDay = DateTime.Parse(sDate).DayOfWeek.ToString();
                    model.WorkFlag = wFlag;
                    model.HollDayFlag = hFlag;
                    model.Remark = remark;
                    model.UpdateUser = CurrentUserInfo.Personcode;
                    succeed = bll.UpdateBGCalendarByKey(model,logmodel);

                }
                for (i = wDay + 1; i < ((days + wDay) + 1); i++)
                {
                    dlstWorkFlag = (DropDownList)this.FindControl("ddlWorkFlag" + i.ToString());
                    dlstWorkFlag.Enabled = false;
                    dlstHolidayFlag = (DropDownList)this.FindControl("ddlHolidayFlag" + i.ToString());
                    dlstHolidayFlag.Enabled = false;
                    txt = (TextBox)this.FindControl("txtRemark" + i.ToString());
                    if (txt.Text.Trim() != "")
                    {
                        txt.ReadOnly = true;
                        txt.BorderStyle = BorderStyle.None;
                    }
                    else
                    {
                        txt.Visible = false;
                    }
                }
                if (succeed)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.UpdateSuccess + "');", true);
                    DataBind();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.UpdateFailed + "');", true);

                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "isnumber", "alert('" + Message.ErrorInfo + "');", true);

            }
        }
コード例 #2
0
        private void getData(int iWDay, int nowDays)
        {
            int index = 0;
            string sDate = "";
            string sql = "";

            for (int i = 1; i < (nowDays + 1); i++)
            {
                BGCalendarModel model = new BGCalendarModel();
                TextBox txt;
                sDate = this.ddlYear.SelectedValue + "/" + this.ddlMonth.SelectedValue + "/" + i.ToString();
                DateTime workday = Convert.ToDateTime(sDate);
                index = i + iWDay;
                model.WorkDay = workday;
                model.BgCode = ddlBG.SelectedValue;
                DataTable dt = bll.GetBGCalendar(model);
                if (dt.Rows.Count > 0)
                {
                    DropDownList dlstWorkFlag = (DropDownList)this.FindControl("ddlWorkFlag" + index.ToString());
                    dlstWorkFlag.SelectedIndex = dlstWorkFlag.Items.IndexOf(dlstWorkFlag.Items.FindByValue(dt.Rows[0]["WorkFlag"].ToString()));
                    DropDownList dlstHolidayFlag = (DropDownList)this.FindControl("ddlHolidayFlag" + index.ToString());
                    dlstHolidayFlag.SelectedIndex = dlstHolidayFlag.Items.IndexOf(dlstHolidayFlag.Items.FindByValue(dt.Rows[0]["HolidayFlag"].ToString()));
                    if (!dt.Rows[0]["Remark"].ToString().Trim().Equals(""))
                    {
                        txt = (TextBox)this.FindControl("txtRemark" + index.ToString());
                        txt.Visible = true;
                        txt.Text = dt.Rows[0]["Remark"].ToString();
                        txt.ReadOnly = true;
                    }
                    else
                    {
                        txt = (TextBox)this.FindControl("txtRemark" + index.ToString());
                        txt.Visible = false;
                        txt.Text = "";
                        txt.ReadOnly = true;
                    }
                }
                else
                {
                    txt = (TextBox)this.FindControl("txtRemark" + index.ToString());
                    txt.Visible = false;
                    txt.Text = "";
                    txt.ReadOnly = true;
                }
            }
        }