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(); } }