private Entities.CustLastOperTask LoadSingleCustLastOperTask(DataRow row) { Entities.CustLastOperTask model = new Entities.CustLastOperTask(); model.CustID = row["CustID"].ToString(); model.TaskID = row["TaskID"].ToString(); if (row["TaskType"].ToString() != "") { model.TaskType = int.Parse(row["TaskType"].ToString()); } if (row["LastOperTime"].ToString() != "") { model.LastOperTime = DateTime.Parse(row["LastOperTime"].ToString()); } if (row["LastOperUserID"].ToString() != "") { model.LastOperUserID = int.Parse(row["LastOperUserID"].ToString()); } if (row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["CreateUserID"].ToString() != "") { model.CreateUserID = int.Parse(row["CreateUserID"].ToString()); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SqlTransaction sqltran, Entities.CustLastOperTask model) { SqlParameter[] parameters = { new SqlParameter("@CustID", SqlDbType.VarChar, 50), new SqlParameter("@TaskID", SqlDbType.VarChar, 20), new SqlParameter("@TaskType", SqlDbType.Int, 4), new SqlParameter("@LastOperTime", SqlDbType.DateTime), new SqlParameter("@LastOperUserID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@CreateUserID", SqlDbType.Int, 4) }; parameters[0].Value = model.CustID; parameters[1].Value = model.TaskID; parameters[2].Value = model.TaskType; parameters[3].Value = model.LastOperTime; parameters[4].Value = model.LastOperUserID; parameters[5].Value = model.CreateTime; parameters[6].Value = model.CreateUserID; return(SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_CUSTLASTOPERTASK_UPDATE, parameters)); }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(Entities.CustLastOperTask model) { SqlParameter[] parameters = { new SqlParameter("@CustID", SqlDbType.VarChar, 50), new SqlParameter("@TaskID", SqlDbType.VarChar, 20), new SqlParameter("@TaskType", SqlDbType.Int, 4), new SqlParameter("@LastOperTime", SqlDbType.DateTime), new SqlParameter("@LastOperUserID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@CreateUserID", SqlDbType.Int, 4) }; parameters[0].Value = model.CustID; parameters[1].Value = model.TaskID; parameters[2].Value = model.TaskType; parameters[3].Value = model.LastOperTime; parameters[4].Value = model.LastOperUserID; parameters[5].Value = model.CreateTime; parameters[6].Value = model.CreateUserID; SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_CUSTLASTOPERTASK_INSERT, parameters); }
private void GenByDataTable(Entities.ProjectInfo ProjectModel, int userId, DataTable dt, out string msg) { msg = ""; #region 根据数据关联生成任务 List <Entities.ProjectTaskInfo> list = new List <Entities.ProjectTaskInfo>(); Entities.ProjectTaskInfo ptaskModel = null; List <Entities.CustLastOperTask> list_OperTask = new List <Entities.CustLastOperTask>(); List <Entities.CustLastOperTask> list_OldOperTask = new List <Entities.CustLastOperTask>(); int maxcount = BLL.ProjectTaskInfo.Instance.GetMax();//从ProjectTaskInfo表中查找最大值 string PixStr = ""; if (ProjectModel.Source == 1) { PixStr = "IMP"; } else if (ProjectModel.Source == 2) { PixStr = "CRM"; } DateTime dtime = DateTime.Now; foreach (DataRow dr in dt.Rows) { ptaskModel = new Entities.ProjectTaskInfo(); ptaskModel.PTID = PixStr + (++maxcount).ToString().PadLeft(7, '0'); ptaskModel.PDSID = long.Parse(dr["PDSID"].ToString()); ptaskModel.ProjectID = int.Parse(ProjectID); ptaskModel.CustName = dr["CustName"].ToString(); //客户名称 ptaskModel.Source = int.Parse(dr["Source"].ToString()); ptaskModel.RelationID = dr["RelationID"].ToString(); ptaskModel.CrmCustID = dr["CustID"].ToString();//CRM客户ID ptaskModel.CreateTime = dtime; ptaskModel.CreateUserID = userId; ptaskModel.LastOptTime = dtime; ptaskModel.LastOptUserID = userId; ptaskModel.TaskStatus = (int)(EnumProjectTaskStatus.NoSelEmployee); ptaskModel.Status = 0; ptaskModel.CustType = dr["CustType"].ToString(); list.Add(ptaskModel); if (PixStr == "CRM") { Entities.CustLastOperTask operTaskModel = new BitAuto.ISDC.CC2012.Entities.CustLastOperTask(); if (ptaskModel.CrmCustID != "") { Entities.CustLastOperTask oldModel = BLL.CustLastOperTask.Instance.GetCustLastOperTask(ptaskModel.CrmCustID); if (oldModel == null) { operTaskModel.CustID = ptaskModel.CrmCustID; operTaskModel.TaskID = ptaskModel.PTID; operTaskModel.TaskType = 1; operTaskModel.LastOperUserID = operTaskModel.CreateUserID = BLL.Util.GetLoginUserID(); operTaskModel.LastOperTime = operTaskModel.CreateTime = dtime; list_OperTask.Add(operTaskModel); list_OldOperTask.Add(null); } else { operTaskModel.CustID = ptaskModel.CrmCustID; operTaskModel.TaskID = ptaskModel.PTID; operTaskModel.LastOperUserID = BLL.Util.GetLoginUserID(); operTaskModel.LastOperTime = dtime; list_OperTask.Add(operTaskModel); list_OldOperTask.Add(oldModel); } } } } string connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC"); SqlConnection connection = new SqlConnection(connectionstrings); connection.Open(); SqlTransaction tran = connection.BeginTransaction("SampleTransaction"); try { //add by qizq 2013-3-11 4S和非4S电话营销 if (ProjectModel.Source != 3) //Modify By Chybin At 2014-3-31 { #region 生成任务 foreach (Entities.ProjectTaskInfo item in list) { BLL.ProjectTaskInfo.Instance.Add(tran, item); } BLL.ProjectLog.Instance.InsertProjectLog(ProjectModel.ProjectID, ProjectLogOper.L6_生成任务, "生成任务" + list.Count + "条", tran); #endregion } #region 修改项目状态 ProjectModel.Status = 1; BLL.ProjectInfo.Instance.Update(tran, ProjectModel); #endregion #region 修改关联数据状态 BLL.ProjectDataSoure.Instance.UpdateStatusByProjectId(tran, "1", (int)ProjectModel.ProjectID); #endregion tran.Commit(); } catch (Exception ex) { if (tran.Connection != null) { tran.Rollback(); } msg = ex.Message.ToString(); } finally { connection.Close(); } #endregion }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Entities.CustLastOperTask model) { return(Dal.CustLastOperTask.Instance.Update(model)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SqlTransaction sqltran, Entities.CustLastOperTask model) { return(Dal.CustLastOperTask.Instance.Update(sqltran, model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(SqlTransaction sqltran, Entities.CustLastOperTask model) { Dal.CustLastOperTask.Instance.Insert(sqltran, model); }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(Entities.CustLastOperTask model) { Dal.CustLastOperTask.Instance.Insert(model); }
private void StopTask(out string msg) { msg = ""; int userId = BLL.Util.GetLoginUserID(); if (BLL.Util.CheckRight(userId, "SYS024BUT150104")) //添加“任务列表--其它任务”结束验证逻辑 { msg += "没有结束权限"; return; } #region ID列表串 string taskIDStr = ""; string[] tidList = TaskIDS.Split(','); foreach (string item in tidList) { taskIDStr += "'" + item + "',"; } if (taskIDStr != "") { taskIDStr = taskIDStr.Substring(0, taskIDStr.Length - 1); } else { msg += "请选择任务"; return; } #endregion #region 判断任务状态 //判断任务状态 DataTable taskDt = BLL.ProjectTaskInfo.Instance.GetTaskInfoListByIDs(taskIDStr); if (taskDt != null) { foreach (DataRow dr in taskDt.Rows) { if (dr["TaskStatus"].ToString() == "180014" || dr["TaskStatus"].ToString() == "180015" || dr["TaskStatus"].ToString() == "180016") { msg += "所选任务中,存在不允许结束的任务"; break; } } if (msg != "") { return; } } else { msg += "没找到对应任务"; } List <Entities.CustLastOperTask> list_OperTask = new List <Entities.CustLastOperTask>(); List <Entities.CustLastOperTask> list_OldOperTask = new List <Entities.CustLastOperTask>(); DateTime operTime = DateTime.Now; for (int p = 0; p < taskDt.Rows.Count; p++) { if (taskDt.Rows[p]["CRMCustID"].ToString() != "") { Entities.CustLastOperTask operTaskModel = new CustLastOperTask(); Entities.CustLastOperTask operOldTaskModel = null; operOldTaskModel = BLL.CustLastOperTask.Instance.GetCustLastOperTask(taskDt.Rows[p]["CRMCustID"].ToString()); if (operOldTaskModel != null) { list_OldOperTask.Add(operOldTaskModel); operTaskModel.CustID = taskDt.Rows[p]["CRMCustID"].ToString(); operTaskModel.TaskID = taskDt.Rows[p]["PTID"].ToString(); operTaskModel.TaskType = 1; operTaskModel.LastOperTime = operTime; operTaskModel.LastOperUserID = BLL.Util.GetLoginUserID(); list_OperTask.Add(operTaskModel); } } } #endregion #region 改变状态 foreach (string item in tidList) { BLL.ProjectTaskInfo.Instance.UpdateTaskStatus(item, EnumProjectTaskStatus.STOPTask, EnumProjectTaskOperationStatus.TaskFinish, operTime); } #endregion }
private void AssignTaskByUseid(out string msg) { msg = ""; int userId = BLL.Util.GetLoginUserID(); if (BLL.Util.CheckRight(userId, "SYS024BUT150102")) //添加“任务列表--其它任务”回收验证逻辑 { msg += "没有回收权限"; return; } #region ID列表串 string taskIDStr = ""; string[] tidList = TaskIDS.Split(','); foreach (string item in tidList) { taskIDStr += "'" + item + "',"; } if (taskIDStr != "") { taskIDStr = taskIDStr.Substring(0, taskIDStr.Length - 1); } else { msg += "请选择任务"; return; } #endregion #region 判断任务状态 //判断任务状态 DataTable taskDt = BLL.ProjectTaskInfo.Instance.GetTaskInfoListByIDs(taskIDStr); if (taskDt != null) { foreach (DataRow dr in taskDt.Rows) { if (dr["TaskStatus"].ToString() != "180012" && dr["TaskStatus"].ToString() != "180000" && dr["TaskStatus"].ToString() != "180001") { msg += "所选任务中,存在不允许分配的任务"; break; } } if (msg != "") { return; } } else { msg += "没找到对应任务"; } List <Entities.CustLastOperTask> list_OperTask = new List <Entities.CustLastOperTask>(); List <Entities.CustLastOperTask> list_OldOperTask = new List <Entities.CustLastOperTask>(); DateTime operTime = DateTime.Now; for (int p = 0; p < taskDt.Rows.Count; p++) { if (taskDt.Rows[p]["CRMCustID"].ToString() != "") { Entities.CustLastOperTask operTaskModel = new CustLastOperTask(); Entities.CustLastOperTask operOldTaskModel = null; operOldTaskModel = BLL.CustLastOperTask.Instance.GetCustLastOperTask(taskDt.Rows[p]["CRMCustID"].ToString()); if (operOldTaskModel != null) { list_OldOperTask.Add(operOldTaskModel); operTaskModel.CustID = taskDt.Rows[p]["CRMCustID"].ToString(); operTaskModel.TaskID = taskDt.Rows[p]["PTID"].ToString(); operTaskModel.TaskType = 1; operTaskModel.LastOperTime = operTime; operTaskModel.LastOperUserID = BLL.Util.GetLoginUserID(); list_OperTask.Add(operTaskModel); } } } #endregion #region MyRegion Entities.ProjectTask_Employee model = null; List <Entities.ProjectTask_Employee> list = new List <Entities.ProjectTask_Employee>(); foreach (string str in tidList) { model = new Entities.ProjectTask_Employee(); model.PTID = str; model.UserID = int.Parse(AssignUserID); model.Status = 0; model.CreateTime = operTime; model.CreateUserID = userId; list.Add(model); } #endregion #region 除原分配信息,插入新分配信息 BLL.ProjectTask_Employee.Instance.DeleteByIDs(taskIDStr); foreach (Entities.ProjectTask_Employee item in list) { BLL.ProjectTask_Employee.Instance.Add(item); } //BLL.ProjectTask_Employee.Instance.UpdateStatus(taskIDStr, "180000"); foreach (string item in tidList) { BLL.ProjectTaskInfo.Instance.UpdateTaskStatus(item, EnumProjectTaskStatus.NoAssign, EnumProjectTaskOperationStatus.TaskAllot, operTime); } #endregion }
/// <summary> /// 回收任务 /// </summary> /// <param name="msg"></param> private void RecedeTask(out string msg) { msg = ""; #region ID列表串 string taskIDStr = ""; string[] tidList = TaskIDS.Split(','); foreach (string item in tidList) { taskIDStr += "'" + item + "',"; } if (taskIDStr != "") { taskIDStr = taskIDStr.Substring(0, taskIDStr.Length - 1); } else { msg += "请选择任务"; return; } #endregion #region 判断任务状态 //判断任务状态 DataTable taskDt = BLL.ProjectTaskInfo.Instance.GetTaskInfoListByIDs(taskIDStr); if (taskDt != null) { foreach (DataRow dr in taskDt.Rows) { if (dr["TaskStatus"].ToString() != "180001" && dr["TaskStatus"].ToString() != "180000") { msg += "所选任务中,存在不允许收回的任务"; break; } } if (msg != "") { return; } } else { msg += "没找到对应任务"; } List <Entities.CustLastOperTask> list_OperTask = new List <Entities.CustLastOperTask>(); List <Entities.CustLastOperTask> list_OldOperTask = new List <Entities.CustLastOperTask>(); DateTime operTime = DateTime.Now; for (int p = 0; p < taskDt.Rows.Count; p++) { if (taskDt.Rows[p]["CRMCustID"].ToString() != "") { Entities.CustLastOperTask operTaskModel = new CustLastOperTask(); Entities.CustLastOperTask operOldTaskModel = null; operOldTaskModel = BLL.CustLastOperTask.Instance.GetCustLastOperTask(taskDt.Rows[p]["CRMCustID"].ToString()); if (operOldTaskModel != null) { list_OldOperTask.Add(operOldTaskModel); operTaskModel.CustID = taskDt.Rows[p]["CRMCustID"].ToString(); operTaskModel.TaskID = taskDt.Rows[p]["PTID"].ToString(); operTaskModel.TaskType = 1; operTaskModel.LastOperTime = operTime; operTaskModel.LastOperUserID = BLL.Util.GetLoginUserID(); list_OperTask.Add(operTaskModel); } } } #endregion #region 除 BLL.ProjectTask_Employee.Instance.DeleteByIDs(taskIDStr); #endregion #region 改状态 foreach (string item in tidList) { BLL.ProjectTaskInfo.Instance.UpdateTaskStatus(item, EnumProjectTaskStatus.NoSelEmployee, EnumProjectTaskOperationStatus.TaskBack, operTime); } #endregion }