예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(QueryString["id"]))
                {
                    btnSave.Enabled = false;
                }
                else
                {
                    userId = QueryString["id"];
                    if (!Page.IsPostBack)
                    {
                        DataFrom dataFrom = new DataFrom();
                        string   userName = dataFrom.GetScalar("select name from s_user where id='" + userId + "'");
                        literalUsers.Text = String.Format("{0}[{1}]", userName, userId);

                        string sql = @"SELECT s_role.ID,s_role.NAME,case when s_roleuser.RoleID is null then 0 else 1 end as issel 
 FROM s_role
 left join  s_roleuser on s_roleuser.RoleID=s_role.ID and s_roleuser.uid='" + userId + @"'
 WHERE s_role.Iflag>0 and '" + CurrentUser.DepID + "' like s_role.depid+'%'";

                        dataFrom.BindListCtrl(sql, chkListRoles, false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("初始化失败", ex);
                RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
            }
        }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     deal = new DataFrom();
     try
     {
         if (!this.IsPostBack)
         {
             WebHelper.SetControlAttributes(btnBuild, new TextBoxVal[] { StartDate, EndDate });
             string   sDate     = deal.GetScalar("SELECT MAX(WORKDAY)+1 FROM WORKWEEK");
             DateTime startDate = DateTime.Today;
             if (!String.IsNullOrEmpty(sDate))
             {
                 StartDate.Enabled = false;
                 startDate         = DataHelper.GetDateValue(sDate, DateTime.Today);
             }
             StartDate.Text = startDate.ToString(Constants.DATE_FORMART);
             EndDate.Text   = startDate.AddYears(1).ToString(Constants.DATE_FORMART);
         }
         SetWorkWeekInfo();
     }
     catch (Exception ex)
     {
         Logger.Error("初始化失败", ex);
         RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
         return;
     }
     if (!Page.IsPostBack)
     {
         if (dtWorkWeek == null || dtWorkWeek.Rows.Count == 0)
         {
             Alert("尚无设置工作日期,请先生成(一般生成一年的数据后再根据节假日调整)");
         }
     }
 }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     RomoveLink();
     roleId = QueryString["id"];
     if (!Page.IsPostBack)
     {
         if (String.IsNullOrEmpty(roleId))
         {
             Close("请先选择角色再进行菜单权限分配");
         }
         string strSql = "";
         try
         {
             DataFrom dataFrom = new DataFrom();
             lblRoleName.Text = dataFrom.GetScalar("select name from s_role where Id='" + roleId + "' and depid='" + CurrentUser.DepID + "'");
             strSql           = @"select f.id,f.Name as text,case when rf.roleid is null then 0 else 1 end as checked,f.parentid,f.sn 
                         from S_Fun f
                         left join S_RoleFun rf on rf.funid=f.id and rf.RoleId=" + roleId
                                + " where f.iflag=1 order by f.SN";
             DataTable dt = dataFrom.GetDataTable(strSql);
             if (dt != null)
             {
                 WebHelper.BindTreeView(dt, "0", tvFunctions);
             }
         }
         catch (Exception ex)
         {
             Logger.Error(strSql, ex);
             RedirectError("角色功能编辑初始化失败,请稍候再试。原因:" + ex.Message);
         }
     }
 }
예제 #4
0
        protected void btnBuild_Click(object sender, EventArgs e)
        {
            DateTime startDate = DataHelper.GetDateValue(StartDate.Text, DateTime.Today);
            DateTime endDate   = DataHelper.GetDateValue(EndDate.Text, DateTime.Today);

            if (startDate > endDate)
            {
                Alert("您要生成的日期的开始日期不能大于截止日期", EndDate.ClientID);
                return;
            }
            int weekStart = DataHelper.GetIntValue(WebHelper.GetAppConfig("WeekStart"), 0);
            int weekcount = DataHelper.GetWeekOfYear(startDate);

            //如果开始日期不是周开始日期向前修正为周开始日期
            startDate = DataHelper.GetWeekStart(startDate, weekStart);
            //如果总星期计数存在,则取最大值加1,否则将其置为1
            int    weekid    = DataHelper.GetIntValue(deal.GetScalar("select max(weekid)+1 from workweek"), 1);
            string insertSql = "insert workweek (weekid, workday, iflag, weeksn) values ({0}, '{1}', {2}, {3})";

            while (startDate <= endDate)
            {
                //周跨年度是作为下一年的 第一周
                if (startDate.AddDays(7).Year > startDate.Year)
                {
                    weekcount = 1;
                }
                for (int j = 0; j < 7; j++)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Saturday || startDate.DayOfWeek == DayOfWeek.Sunday)
                    {
                        deal.SqlExecute(String.Format(insertSql, weekid, startDate, 0, weekcount));
                    }
                    else
                    {
                        deal.SqlExecute(String.Format(insertSql, weekid, startDate, 1, weekcount));
                    }
                    startDate = startDate.AddDays(1);
                }
                weekcount++;
                weekid++;
            }
            Response.Redirect(Request.Url.AbsoluteUri);
        }