Example #1
0
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool UpgradeList(List <TaskStageTemplate> list)
        {
            int errCount = 0;

            foreach (TaskStageTemplate element in list)
            {
                string sqlStr = "if exists (select 1 from TaskStageTemplate where ID=" + element.ID + ") update TaskStageTemplate set Name='" + element.Name + "', Executors='" + element.Executors + "', Approvers='" + element.Approvers + "' where ID=" + element.ID + " else insert into TaskStageTemplate (Name, Executors, Approvers) values ('" + element.Name + "', '" + TaskStage.GetUserIds(element.Executors) + "', '" + TaskStage.GetUserIds(element.Approvers) + "')";
                try
                {
                    sqlHelper.ExecuteSql(sqlStr);
                }
                catch (Exception)
                {
                    errCount++;
                }
            }
            return(errCount == 0);
        }
Example #2
0
        public int AddTaskStageTemplate(TaskStageTemplate element)
        {
            string sql = "insert into TaskStageTemplate (Name, Executors, Approvers) values ('" + element.Name + "', '" + TaskStage.GetUserIds(element.Executors) + "', '" + TaskStage.GetUserIds(element.Approvers) + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }