protected void search_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(dlUserName.SelectedValue))
     {
         lblMessage.Text = "该年内无用户数据!";
         return;
     }
     if (dlUserName.SelectedValue == "All" && dlWorkTime.SelectedValue == "All")
     {
         lblMessage.Text = "不支持用户名“全选”和工作名“全选”的查询功能";
         return;
     }
     lblMessage.Text = "";
     searchCondition = new SearchCondition();
     searchCondition.Department = System.Configuration.ConfigurationManager.AppSettings["Department"];
     searchCondition.Year = dlYear.SelectedValue;
     searchCondition.Month = dlMonth.SelectedValue;
     searchCondition.UserName = dlUserName.SelectedValue;
     searchCondition.WorkTime = dlWorkTime.SelectedValue;
     gvShowUsersBind();
 }
 protected void init()
 {
     searchCondition = new SearchCondition();
     searchCondition.Department = System.Configuration.ConfigurationManager.AppSettings["Department"];
     GetDepartmentName();
     dlYearBind();
     dlUserNameBind(searchCondition.Year);
     dlWorkTimeBind();
     dlMonthBind();
     gvShowUsersBind();
 }
        protected void gvShowUsers_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //输入的应该为数值,不能为字母等
            // Handle the new and original values.
            var newValues = e.NewValues;
            var oldValues = e.OldValues;

            lblMessage.Text = "";
            searchCondition = new SearchCondition();
            searchCondition.Department = System.Configuration.ConfigurationManager.AppSettings["Department"];
            searchCondition.UserName = oldValues[0].ToString();
            searchCondition.Year = oldValues[2].ToString();
            var workTimeDic = new BindXML().BindWorkTime();
            string workTimeKey = " ";
            bool findWorkKey = workTimeDic.TryGetValue(oldValues[1].ToString(), out workTimeKey);
            searchCondition.WorkTime = workTimeKey; //需改成WorkTime的格式
            var monthDic = new BindXML().BindMonths();
            string month = " ";
            bool findMonth = monthDic.TryGetValue(oldValues[3].ToString(), out month);
            searchCondition.Month = month;  //需改成月的格式

            new BindXML().UpdateUsersDays(int.Parse(searchCondition.Year), searchCondition.UserName, searchCondition.WorkTime, searchCondition.Month, (OrderedDictionary)newValues, (OrderedDictionary)oldValues);
            gvShowUsersBind();
        }
        protected void gvShowUsers_RowEditing(object sender, GridViewEditEventArgs e)
        {
            //输入的应该为数值,不能为字母等
            // Handle the new and original values.
            GridViewRow row = gvShowUsers.Rows[e.NewEditIndex];

            String workTime = row.Cells[2].Text;
            //在此处需过滤一些数据,比如不能够 修改WorkTime为“总计”的数据
            if (workTime == "总计")
            {
                lblMessage.Text = "不能修改“总计”项!";
                e.Cancel = true;

            }
            else
            {
                lblMessage.Text = "";
                searchCondition = new SearchCondition();
                searchCondition.Department = System.Configuration.ConfigurationManager.AppSettings["Department"];
                searchCondition.UserName = row.Cells[1].Text;
                searchCondition.Year = row.Cells[3].Text;
                var workTimeDic = new BindXML().BindWorkTime();
                string workTimeKey = " ";
                bool findWorkKey = workTimeDic.TryGetValue(row.Cells[2].Text, out workTimeKey);
                searchCondition.WorkTime = workTimeKey; //需改成WorkTime的格式
                var monthDic = new BindXML().BindMonths();
                string month = " ";
                bool findMonth = monthDic.TryGetValue(row.Cells[4].Text, out month);
                searchCondition.Month = month;  //需改成月的格式
                gvShowUsersBind();
            }
        }
 protected void gvShowUsers_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     lblMessage.Text = "";
     searchCondition = new SearchCondition();
     searchCondition.Department = System.Configuration.ConfigurationManager.AppSettings["Department"];
     searchCondition.Year = dlYear.SelectedValue;
     searchCondition.Month = dlMonth.SelectedValue;
     searchCondition.UserName = dlUserName.SelectedValue;
     searchCondition.WorkTime = dlWorkTime.SelectedValue;
     gvShowUsersBind();
 }
示例#6
0
 protected void gvShowUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     searchCondition = new SearchCondition();
     searchCondition.Department = System.Configuration.ConfigurationManager.AppSettings["Department"];
     searchCondition.Year = dlYear.SelectedValue;
     searchCondition.Month = dlMonth.SelectedValue;
     searchCondition.UserName = dlUserName.SelectedValue;
     searchCondition.WorkTime = dlWorkTime.SelectedValue;
     gvShowUsersBind(e.NewPageIndex);
 }