protected void btn_Delete_Click(object sender, EventArgs e) { try { string ids = this.hf_CheckIDS.Value.TrimEnd(','); using (IFMPDBContext db = new IFMPDBContext()) { try { foreach (string id in ids.Split(',')) { int selid = Convert.ToInt32(id); BaseDateFlow BaseDateFlow = db.BaseDateFlow.FirstOrDefault(t => t.ID == selid); db.BaseDateFlow.Remove(BaseDateFlow); } db.SaveChanges(); new SysLogDAO().AddLog(LogType.操作日志_删除, "删除基础时间设置信息", UserID); ShowMessage("删除成功"); } catch { ShowMessage("删除失败"); return; } } } catch (Exception ex) { new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); ShowMessage(ex.Message); } this.hf_CheckIDS.Value = ""; DataBindList(); }
public void BindInfo() { using (IFMPDBContext db = new IFMPDBContext()) { BaseDateFlow BaseDateFlow = db.BaseDateFlow.FirstOrDefault(t => t.ID == BaseDateFlowID); if (BaseDateFlow != null) { this.ddl_TableType.SelectedValue = BaseDateFlow.TableTypeID.ToString(); this.ddl_ClassType.SelectedValue = BaseDateFlow.ClassType.ToString(); this.ddl_Flow.SelectedValue = BaseDateFlow.FlowID.ToString(); this.txt_BeginDate.Text = BaseDateFlow.BeginDate.ToString("HH:mm:ss"); this.txt_EndDate.Text = BaseDateFlow.EndDate.ToString("HH:mm:ss"); this.txt_RemindDate.Text = BaseDateFlow.RemindDate.ToString("HH:mm:ss"); } } }
protected void rp_List_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { int clatype = Convert.ToInt32(this.ddl_ClassType.SelectedValue.ToString()); //班次类型 int tabtype = Convert.ToInt32(this.ddl_TableType.SelectedValue.ToString()); //表单类型 HiddenField hfFlowID = (HiddenField)e.Item.FindControl("hf_FlowID"); int flowid = Convert.ToInt32(hfFlowID.Value); CheckBoxList chk = (CheckBoxList)e.Item.FindControl("chk_ClassList"); TextBox txt_SysUser = (TextBox)e.Item.FindControl("txt_SysUser"); Literal ltl_Content = (Literal)e.Item.FindControl("ltl_Content"); TextBox txt_BeginDate = (TextBox)e.Item.FindControl("txt_BeginDate"); TextBox txt_EndDate = (TextBox)e.Item.FindControl("txt_EndDate"); TextBox txt_RemindDate = (TextBox)e.Item.FindControl("txt_RemindDate"); //根据班次类型获取所有班次信息 List <BaseClass> classlist = db.BaseClass.Where(t => t.ClassType == (ClassTypeEnums)clatype && t.IsDel != true).ToList(); List <BaseClassUser> bassclassuserlist = db.BaseClassUser.ToList(); List <object> list = new List <object>(); if (classlist.Count > 0) { List <User> UserList = db.User.Where(t => t.IsDel != true).ToList(); foreach (BaseClass bclass in classlist) { //根据班次ID和流程ID获取班次人员信息,绑定CheckBoxlist string name = ""; List <BaseClassUser> classuserlist = bassclassuserlist.Where(t => t.BaseClassID == bclass.ID && t.FlowID == flowid).ToList(); if (classuserlist.Count > 0) { foreach (BaseClassUser classuser in classuserlist) { name += UserList.FirstOrDefault(t => t.ID == classuser.UserID) == null ? "" : (UserList.FirstOrDefault(t => t.ID == classuser.UserID).RealName + ","); } } name = name.TrimEnd(',').TrimStart(','); list.Add(new { Name = bclass.Name + "(" + name + ")", bclass.ID }); } } if (list.Count > 0) { chk.DataTextField = "Name"; chk.DataValueField = "ID"; chk.DataSource = list; chk.DataBind(); } StringBuilder sb = new StringBuilder(""); string a = MList(flowid); sb.Append("<script type='text/javascript'>"); sb.Append(" $(function () {"); sb.Append(" $('#" + txt_SysUser.ClientID + "').combotree({"); sb.Append(" data: [ "); sb.Append(a); sb.Append("],"); sb.Append("multiple: true,"); sb.Append("multiline: true,"); sb.Append("onlyLeafCheck:'true',"); sb.Append("lines: true,"); sb.Append("});"); sb.Append(" }); </script>"); ltl_Content.Text = sb.ToString(); //添加绑定 if (TaskID == -1) { BaseDateFlow dateflow = db.BaseDateFlow.FirstOrDefault(t => t.FlowID == flowid && t.ClassType == (ClassTypeEnums)clatype && t.TableTypeID == tabtype); if (dateflow != null) { txt_BeginDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), dateflow.BeginDate).ToString("yyyy-MM-dd HH:mm:ss"); txt_EndDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), dateflow.EndDate).ToString("yyyy-MM-dd HH:mm:ss"); txt_RemindDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), dateflow.RemindDate).ToString("yyyy-MM-dd HH:mm:ss"); } } else {//编辑绑定 List <TaskFlow> taskflowlist = db.TaskFlow.Where(t => t.TaskID == TaskID && t.FlowID == flowid).ToList(); if (taskflowlist.Count > 0) { //获取taskflow表的班次信息 var testlist = taskflowlist.Where(t => t.BaseClassID != null).Select(t => t.BaseClassID).Distinct().ToList(); for (int i = 0; i < testlist.Count; i++) { int classid = Convert.ToInt32(testlist[i].ToString()); for (int j = 0; j < chk.Items.Count; j++) { if (chk.Items[j].Value == classid.ToString()) { chk.Items[j].Selected = true; } } TaskFlow taskflow = taskflowlist.FirstOrDefault(t => t.BaseClassID == classid); if (taskflow != null) { //txt_BeginDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), taskflow.BeginDate).ToString("yyyy-MM-dd HH:mm:ss"); //txt_EndDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), taskflow.EndDate).ToString("yyyy-MM-dd HH:mm:ss"); //txt_RemindDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), taskflow.RemindDate).ToString("yyyy-MM-dd HH:mm:ss"); txt_BeginDate.Text = taskflow.BeginDate.ToString("yyyy-MM-dd HH:mm:ss"); txt_EndDate.Text = taskflow.EndDate.ToString("yyyy-MM-dd HH:mm:ss"); txt_RemindDate.Text = taskflow.RemindDate.ToString("yyyy-MM-dd HH:mm:ss"); } } string ids = ""; List <TaskFlow> flowlist = taskflowlist.Where(t => t.BaseClassID == null).ToList(); foreach (TaskFlow taskflow in flowlist) { ids += taskflow.UserID + ","; } txt_SysUser.Text = ids.TrimEnd(',').TrimStart(','); } } } }
public ApiResult Add(TaskAdd TaskAdd) { ApiResult result = new ApiResult(); string message = string.Empty; Action action = () => { using (FLDbContext db = new FLDbContext()) { foreach (FLTask Task in TaskAdd.TaskList) { if (string.IsNullOrEmpty(Task.TaskName)) { message = "请填写任务名称"; goto Response; } Task.CreateDate = DateTime.Now; Task.IsDel = false; db.FLTask.Add(Task); db.SaveChanges(); if (Task.IsBaseClass == true) { //使用默认的班次 List <TaskFlow> tfList = new List <TaskFlow>(); List <Flow> FlowList = new FlowDAO().GetFlow(Task.TableType); foreach (BaseClass bs in TaskAdd.BaseClassList) { foreach (Flow Flow in FlowList) { List <BaseClassUser> bculist = db.BaseClassUser.Where(t => t.BaseClassID == bs.ID && t.FlowID == Flow.ID).ToList(); foreach (BaseClassUser bcu in bculist) { foreach (TaskFlow tf in Task.TaskFlowList) { //这里可以缓存一个bdf来提升效率 if (tf.IsBase) { BaseDateFlow bdf = db.BaseDateFlow.FirstOrDefault(t => t.FlowID == tf.FlowID); tf.BeginDate = bdf.BeginDate; tf.EndDate = bdf.EndDate; tf.RemindDate = bdf.RemindDate; } //tf.FlowID = bcu.FlowID; tf.MaintainUserID = bcu.UserID; tf.IsReminded = false; tf.MaintainUserID = bcu.UserID; tf.TaskID = Task.ID; tfList.Add(tf); } } } } db.TaskFlow.AddRange(tfList); } else { //先验证是否完整 List <Flow> flowList = new FlowDAO().GetFlow(Task.TableType); foreach (Flow flow in flowList) { if (Task.TaskFlowList.FirstOrDefault(t => t.FlowID == flow.ID) == null) { message = "请填写完整的流程"; goto Response; } } foreach (TaskFlow tf in Task.TaskFlowList) { if (tf.IsBase) { BaseDateFlow bdf = db.BaseDateFlow.FirstOrDefault(t => t.FlowID == tf.FlowID); tf.BeginDate = bdf.BeginDate; tf.EndDate = bdf.EndDate; tf.RemindDate = bdf.RemindDate; } tf.IsReminded = false; tf.TaskID = Task.ID; } db.TaskFlow.AddRange(Task.TaskFlowList); } } } new SysLogDAO().AddLog(LogType.Success, message: "成功添加任务"); result = ApiResult.NewSuccessJson("成功添加任务"); Response: if (!string.IsNullOrEmpty(message)) { //回滚 foreach (FLTask Task in TaskAdd.TaskList) { if (Task.ID != 0) { new FLDbContext().FLTask.Remove(new FLDbContext().FLTask.FirstOrDefault(t => t.ID == Task.ID)); } else { break; } } result = ApiResult.NewErrorJson(message); } }; TransactioExtension.Excute(action); return(result); }
public void TestMethod1() { try { using (IFMPDBContext db = new IFMPDBContext()) { int BaseClass = 5; int adddays = 1; ClassTypeEnums ClassType = ClassTypeEnums.早班; List <TableType> TableTypeList = db.TableType.Where(t => t.IsDel != true).ToList(); List <Flow> FlowList = db.Flow.ToList(); FlowList = FlowList.Where(t => TableTypeList.Select(m => m.ID).Contains(t.TableTypeID)).ToList(); List <BaseClassUser> BaseClassUserList = db.BaseClassUser.ToList(); List <BaseDateFlow> BaseDateFlowList = db.BaseDateFlow.ToList(); //TASK 添加 foreach (TableType TableType in TableTypeList) { Task Task = new Task(); Task.ClassType = ClassType; Task.CreateDate = DateTime.Now; Task.CreateUserID = 290; Task.IsDel = false; Task.TableTypeID = TableType.ID; Task.TaskName = DateTime.Now.AddDays(adddays).ToString("MM-dd") + Enum.GetName(typeof(ClassTypeEnums), Task.ClassType) + TableType.Name; db.Task.Add(Task); db.SaveChanges(); List <Flow> SelFlowList = FlowList.Where(t => t.TableTypeID == TableType.ID).ToList(); foreach (Flow SelFlow in SelFlowList) { List <BaseClassUser> SelBaseClassUserList = BaseClassUserList.Where(t => t.FlowID == SelFlow.ID && t.BaseClassID == BaseClass).ToList(); BaseDateFlow BaseDateFlow = BaseDateFlowList.FirstOrDefault(t => t.ClassType == ClassType && t.FlowID == SelFlow.ID); foreach (BaseClassUser SelBaseClassUser in SelBaseClassUserList) { TaskFlow TaskFlow = new TaskFlow(); //TaskFlow. TaskFlow.ApplyType = ApplyTypeEnums.未交; TaskFlow.BaseClassID = SelBaseClassUser.BaseClassID; TaskFlow.BeginDate = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(adddays), BaseDateFlow.BeginDate); TaskFlow.EndDate = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(adddays), BaseDateFlow.EndDate); if (TaskFlow.EndDate < TaskFlow.BeginDate) { TaskFlow.EndDate = TaskFlow.EndDate.AddDays(1); } TaskFlow.FlowID = SelFlow.ID; TaskFlow.IsReminded = false; TaskFlow.TaskID = Task.ID; TaskFlow.RemindDate = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(adddays), BaseDateFlow.RemindDate); if (TaskFlow.RemindDate < TaskFlow.BeginDate) { TaskFlow.RemindDate = TaskFlow.RemindDate.AddDays(1); } TaskFlow.UserID = SelBaseClassUser.UserID; db.TaskFlow.Add(TaskFlow); } } db.SaveChanges(); } //List<User> UserList = db.User.Where(t=>); //BaseUtils test = new BaseUtils(); //bool result = test.GetRegex("23.7°", RegexType.度数); //result = test.GetRegex("23.7", RegexType.度数); //result = test.GetRegex("我°", RegexType.度数); //result = test.GetRegex("°", RegexType.度数); //result = test.GetRegex("23.7°°", RegexType.度数); //List<BaseDateFlow> BaseDateFlowList = db.BaseDateFlow.Where(t => t.FlowID > 107 && t.FlowID < 118).ToList(); //foreach (BaseDateFlow BaseDateFlow in BaseDateFlowList) //{ // BaseDateFlow newdata = new BaseDateFlow(); // BaseUtils.DeepCopy(newdata, BaseDateFlow); // if (BaseDateFlow.FlowID != 117) // { // newdata.FlowID = (newdata.FlowID + 24) > 137 ? (newdata.FlowID + 25) : (newdata.FlowID + 24); // } // else // { // newdata.FlowID = 140; // } // newdata.TableTypeID = 20; // db.BaseDateFlow.Add(newdata); //} //db.SaveChanges(); //List<TableColumn> TableColumnList = db.TableColumn.Where(t => t.TableTypeID == 4).ToList(); //foreach (TableColumn TableColumn in TableColumnList) //{ // TableColumn NewTableColumn = new TableColumn(); // BaseUtils.DeepCopy(NewTableColumn, TableColumn); // NewTableColumn.TableTypeID = 23; // db.TableColumn.Add(NewTableColumn); //} //db.SaveChanges(); //List<Flow> FlowList = db.Flow.Where(t => t.TableTypeID == 17).ToList(); //foreach (Flow Flow in FlowList) //{ // Flow NewFlow = new Flow(); // BaseUtils.DeepCopy(NewFlow, Flow); // NewFlow.TableTypeID = 20; // db.Flow.Add(NewFlow); //} //db.SaveChanges(); //flow 43-47删除 //DDUtils test = new DDUtils(); //test.NewPostFile(); //TaskNotice(); } } catch { } }
protected void btn_Sumbit_Click(object sender, EventArgs e) { try { using (IFMPDBContext db = new IFMPDBContext()) { BaseDateFlow BaseDateFlow = db.BaseDateFlow.FirstOrDefault(t => t.ID == BaseDateFlowID); if (BaseDateFlow == null) { BaseDateFlow = new BaseDateFlow(); BaseDateFlow.BeginDate = Convert.ToDateTime(this.txt_BeginDate.Text); BaseDateFlow.EndDate = Convert.ToDateTime(this.txt_EndDate.Text); BaseDateFlow.RemindDate = Convert.ToDateTime(this.txt_RemindDate.Text); if (BaseDateFlow.BeginDate > BaseDateFlow.EndDate || BaseDateFlow.BeginDate > BaseDateFlow.RemindDate || BaseDateFlow.RemindDate > BaseDateFlow.EndDate) { ShowMessage("请至少选择正确的时间(提醒时间需要晚于开始时间,结束时间需要晚于提醒时间)"); return; } BaseDateFlow.ClassType = (ClassTypeEnums)Convert.ToInt32(this.ddl_ClassType.SelectedValue); BaseDateFlow.TableTypeID = Convert.ToInt32(this.ddl_TableType.SelectedValue); BaseDateFlow.FlowID = Convert.ToInt32(this.ddl_Flow.SelectedValue); BaseDateFlow.Name = db.Flow.FirstOrDefault(t => t.ID == BaseDateFlow.FlowID).Name + ":" + Enum.GetName(typeof(ClassTypeEnums), BaseDateFlow.ClassType); //若存在重复的提示,保证同表单同班次只有一个时间 if (db.BaseDateFlow.FirstOrDefault(t => t.FlowID == BaseDateFlow.FlowID && t.ClassType == BaseDateFlow.ClassType && t.TableTypeID == BaseDateFlow.TableTypeID) != null) { ShowMessage("该班次时段已被选择,请在基础时间设置内选择修改"); return; } db.BaseDateFlow.Add(BaseDateFlow); ShowMessage(); new SysLogDAO().AddLog(LogType.操作日志_添加, "添加基础时间设置", UserID); db.SaveChanges(); } else { BaseDateFlow.BeginDate = Convert.ToDateTime(this.txt_BeginDate.Text); BaseDateFlow.EndDate = Convert.ToDateTime(this.txt_EndDate.Text); BaseDateFlow.RemindDate = Convert.ToDateTime(this.txt_RemindDate.Text); if (BaseDateFlow.BeginDate > BaseDateFlow.EndDate || BaseDateFlow.BeginDate > BaseDateFlow.RemindDate || BaseDateFlow.RemindDate > BaseDateFlow.EndDate) { ShowMessage("请至少选择正确的时间(提醒时间需要晚于开始时间,结束时间需要晚于提醒时间)"); return; } BaseDateFlow.ClassType = (ClassTypeEnums)Convert.ToInt32(this.ddl_ClassType.SelectedValue); BaseDateFlow.TableTypeID = Convert.ToInt32(this.ddl_TableType.SelectedValue); BaseDateFlow.FlowID = Convert.ToInt32(this.ddl_Flow.SelectedValue); BaseDateFlow.Name = db.Flow.FirstOrDefault(t => t.ID == BaseDateFlow.FlowID).Name + ":" + Enum.GetName(typeof(ClassTypeEnums), BaseDateFlow.ClassType); //若存在重复的提示,保证同表单同班次只有一个时间 if (db.BaseDateFlow.FirstOrDefault(t => t.FlowID == BaseDateFlow.FlowID && t.ClassType == BaseDateFlow.ClassType && t.TableTypeID == BaseDateFlow.TableTypeID && t.ID != BaseDateFlow.ID) != null) { ShowMessage("该班次时段已被选择,请在基础时间设置内选择修改"); return; } } ShowMessage(); new SysLogDAO().AddLog(LogType.操作日志_修改, "修改基础时间设置", UserID); db.SaveChanges(); } } catch (Exception error) { ShowMessage(error.Message); } }