Esempio n. 1
0
        /// <summary>
        /// 新增对象
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>true=成功;false=失败</returns>
        public bool Insert(PatrolReportDetail entity)
        {
            SQLEntities context = new SQLEntities();
            bool        success = false;

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    context.PatrolReportDetail.AddObject(entity);
                    trans.Complete();
                    success = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            try
            {
                if (success)
                {
                    //提交保存
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            context.Dispose();

            return(success);
        }
Esempio n. 2
0
        /// <summary>
        /// 取得特巡点检详细信息
        /// </summary>
        /// <param name="source"></param>
        /// <param name="header"></param>
        /// <returns></returns>
        private static List <PatrolReportDetail> getDetailList(ReqUploadPatrolInformation source, PatrolReportHeader header, String dirName)
        {
            List <PatrolReportDetail> list = new List <PatrolReportDetail>();

            if (source != null && source.check_list != null && source.check_list.Count > 0 && header != null)
            {
                for (int i = 0; i < source.check_list.Count; i++)
                {
                    PicInfo            item     = source.check_list[i];
                    PatrolReportDetail instance = new PatrolReportDetail();
                    //前端获取
                    instance.IsImportant   = item.is_important;
                    instance.LocationCode  = item.location_code;
                    instance.SpotCode      = item.spot_code;
                    instance.Status        = item.spot_status_code;
                    instance.Remarks       = item.part_remarks;
                    instance.QuestionLevel = item.level_code;
                    instance.PicUrl        = dirName + "/" + item.pic_url;
                    Console.WriteLine(instance.PicUrl);
                    //自动设置
                    instance.PatrolNO   = header.PatrolNO;
                    instance.SubNO      = i;
                    instance.IsSelected = "0";

                    //加入列表
                    list.Add(instance);
                }
            }
            return(list);
        }
Esempio n. 3
0
 /// <summary>
 /// 根据用户名称查询唯一用户
 /// </summary>
 /// <param name="searchInfo">带有PatrolNo的查询对象</param>
 /// <returns>指定UserCD值的个人信息</returns>
 public static PatrolReportDetail Select(PatrolReportDetail searchInfo)
 {
     if (searchInfo == null || searchInfo.PatrolNO == String.Empty || searchInfo.SubNO < 0)
     {
         return(null);
     }
     return(controller.Select(searchInfo));
 }
Esempio n. 4
0
 /// <summary>
 /// 删除记录
 /// </summary>
 /// <param name="entity">删除对象 主键必须设置</param>
 /// <returns></returns>
 public static bool Delete(PatrolReportDetail entity)
 {
     if (entity != null)
     {
         return(controller.Delete(entity));
     }
     return(false);
 }
Esempio n. 5
0
 /// <summary>
 /// 更新记录
 /// </summary>
 /// <param name="entity">要更新对象</param>
 /// <param name="updateKeys">更新列表</param>
 /// <returns>true=成功,false=失败</returns>
 public static bool Update(PatrolReportDetail entity, Hashtable updateKeys)
 {
     if (entity != null && updateKeys != null && updateKeys.Count > 0)
     {
         return(controller.Update(entity, updateKeys));
     }
     return(false);
 }
Esempio n. 6
0
 /// <summary>
 /// 新增记录
 /// </summary>
 /// <param name="entity">新增对象</param>
 /// <returns>true=成功,false=失败</returns>
 public static bool Insert(PatrolReportDetail entity)
 {
     if (entity != null)
     {
         return(controller.Insert(entity));
     }
     return(false);
 }
Esempio n. 7
0
        /// <summary>
        /// 记录需要更新的字段
        /// </summary>
        /// <param name="update"></param>
        private static void SetUpdateValue(PatrolReportDetail current, Hashtable updateKeys)
        {
            foreach (DictionaryEntry item in updateKeys)
            {
                switch (item.Key.ToString().ToLower())
                {
                case "patrolno":
                    current.PatrolNO = item.Value.ToString();
                    break;

                case "subno":
                    current.SubNO = Convert.ToInt32(item.Value);
                    break;

                case "locationcode":
                    current.LocationCode = item.Value.ToString();
                    break;

                case "spotcode":
                    current.SpotCode = item.Value.ToString();
                    break;

                case "status":
                    current.Status = item.Value.ToString();
                    break;

                case "questionlevel":
                    current.QuestionLevel = item.Value.ToString();
                    break;

                case "remarks":
                    current.Remarks = item.Value.ToString();
                    break;

                case "picurl":
                    current.PicUrl = item.Value.ToString();
                    break;

                case "isselected":
                    current.IsSelected = item.Value.ToString();
                    break;

                case "isimportant":
                    current.IsImportant = item.Value.ToString();
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 复制对象
        /// </summary>
        /// <param name="source">源对象</param>
        /// <returns></returns>
        public PatrolReportDetail Copy(PatrolReportDetail source)
        {
            PatrolReportDetail target = new PatrolReportDetail();

            target.PatrolNO      = source.PatrolNO;
            target.SubNO         = source.SubNO;
            target.LocationCode  = source.LocationCode;
            target.SpotCode      = source.SpotCode;
            target.Status        = source.Status;
            target.QuestionLevel = source.QuestionLevel;
            target.Remarks       = source.Remarks;
            target.PicUrl        = source.PicUrl;
            target.IsSelected    = source.IsSelected;
            target.IsImportant   = source.IsImportant;

            return(target);
        }
Esempio n. 9
0
        /// <summary>
        /// 根据查询条件查询单条记录
        /// </summary>
        /// <param name="searchInfo">查询条件,主键查询</param>
        /// <returns></returns>
        public PatrolReportDetail Select(PatrolReportDetail searchInfo)
        {
            PatrolReportDetail instance = null;

            try
            {
                SQLEntities context = new SQLEntities();

                instance = context.PatrolReportDetail.Where("it.PatrolNO=@PatrolNO and it.SubNO =@SubNO", new ObjectParameter("PatrolNO", searchInfo.PatrolNO), new ObjectParameter("SubNO", searchInfo.SubNO)).First();

                context.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(instance);
        }
Esempio n. 10
0
        /// <summary>
        /// 根据主键删除实例
        /// </summary>
        /// <param name="oldEntity">设置了主键Id的对象</param>
        /// <returns></returns>
        public bool Delete(PatrolReportDetail entity)
        {
            SQLEntities context = new SQLEntities();
            bool        success = false;

            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    PatrolReportDetail instance = context.PatrolReportDetail.Where("it.PatrolNO=@PatrolNO and it.SubNO =@SubNO", new ObjectParameter("PatrolNO", entity.PatrolNO), new ObjectParameter("SubNO", entity.SubNO)).First();
                    //标记删除
                    context.PatrolReportDetail.DeleteObject(instance);
                    trans.Complete();
                    success = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            try
            {
                if (success)
                {
                    //提交保存
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            context.Dispose();

            return(success);
        }
Esempio n. 11
0
        /// <summary>
        /// 测试特巡报告详情
        /// </summary>
        public static void TestPatrolReportDetail(string patrolno)
        {
            PatrolReportDetailHelper ph = new PatrolReportDetailHelper();

            PatrolReportDetail target = new PatrolReportDetail();

            target.PatrolNO      = patrolno;
            target.SubNO         = 0;
            target.LocationCode  = "SP0002";
            target.SpotCode      = "SP0002001";
            target.Status        = "1";
            target.QuestionLevel = "1";
            target.Remarks       = "铭牌点检信息";
            target.PicUrl        = "http://www.baidu.com";
            target.IsSelected    = "1";
            target.IsImportant   = "0";

            ph.Insert(target);
            //List<PatrolReportDetail> list = ph.SelectAll();
            //foreach (PatrolReportDetail item in list)
            //{
            //    Console.WriteLine(item.PatrolNO);
            //}
        }