Exemple #1
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="model">日志实体类</param>
        /// <param name="list">汇报集合</param>
        /// <returns></returns>
        public static bool SaveData(PersonalNoteModel model, IList <PersonalNoteReportModel> list)
        {
            ArrayList  sqlList = new ArrayList();
            SqlCommand cmd     = null;

            #region 日志

            if (model.ID.HasValue)
            {// 编号存在更新
                sqlList.Add(PersonalNoteDBHelper.UpdateCommand(model));
            }
            else
            {// 编号不存在保存
                cmd = PersonalNoteDBHelper.InsertCommand(model);
                sqlList.Add(cmd);
            }

            #endregion

            #region 汇报信息

            foreach (PersonalNoteReportModel item in list)
            {
                if (item.ID.HasValue)
                {
                    sqlList.Add(PersonalNoteReportDBHelper.UpdateCommand(item));
                }
                else
                {
                    sqlList.Add(PersonalNoteReportDBHelper.InsertCommand(item));
                }
            }

            #endregion

            // 保存数据
            if (SqlHelper.ExecuteTransWithArrayList(sqlList))
            {
                if (!model.ID.HasValue)
                {
                    int i = 0;
                    if (int.TryParse(cmd.Parameters["@IndexID"].Value.ToString(), out i))
                    {
                        model.ID = i;
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 插入数据记录
        /// </summary>
        ///<param name="model">实体类</param>
        /// <returns>插入数据是否成功:true成功,false不成功</returns>
        public static bool Insert(PersonalNoteModel model)
        {
            ArrayList  sqlList = new ArrayList();
            SqlCommand cmd     = PersonalNoteDBHelper.InsertCommand(model);

            sqlList.Add(cmd);

            if (SqlHelper.ExecuteTransWithArrayList(sqlList))
            {
                int i = 0;
                if (int.TryParse(cmd.Parameters["@IndexID"].Value.ToString(), out i))
                {
                    model.ID = i;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }