コード例 #1
0
 /// <summary>
 /// 获取指定Id记录
 /// </summary>
 /// <param name="id">主键Id</param>
 /// <param name="isCache">是否从缓存中读取</param>
 /// <returns>DataAccess.Model.PREPARE00</returns>
 public DataAccess.Model.PREPARE00 GetModel(long id, bool isCache = true)
 {
     //判断是否使用缓存
     if (CommonBll.IsUseCache() && isCache)
     {
         //从缓存中获取List
         var list = GetList();
         if (list == null)
         {
             return(null);
         }
         else
         {
             //在List查询指定主键Id的记录
             return(list.SingleOrDefault(x => x.Id == id));
         }
     }
     else
     {
         //从数据库中直接读取
         var model = PREPARE00.SingleOrDefault(x => x.Id == id);
         if (model == null)
         {
             return(null);
         }
         else
         {
             //对查询出来的实体进行转换
             return(Transform(model));
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="id">主键Id</param>
        /// <returns>DataAccess.Model.PREPARE00</returns>
        public DataAccess.Model.PREPARE00 GetModelForCache(long id)
        {
            try
            {
                //从缓存中读取指定Id记录
                var model = GetModelForCache(x => x.Id == id);

                if (model == null)
                {
                    //从数据库中读取
                    var tem = PREPARE00.SingleOrDefault(x => x.Id == id);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);
                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取PREPARE00表记录时出现异常", e);

                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 核准按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Btn_MainCheck(Object sender, EventArgs e)
        {
            string _tbxPREPAR_ID = tbxPREPAR_ID.Text.ToString();
            var    model         = PREPARE00.SingleOrDefault(x => x.PREPAR_ID == _tbxPREPAR_ID);

            if (model == null)
            {
                FineUI.Alert.ShowInParent("订单单号不存在", FineUI.MessageBoxIcon.Information);
                return;
            }
            //1 = 存档 2 = 核准 3 = 作废 4 = 已引入(供应商进货)
            switch (model.STATUS)
            {
            case 1: model.STATUS = 2; break;

            case 2: model.STATUS = 1; break;

            case 3: FineUI.Alert.ShowInParent("订单已作废,无法进行核准", FineUI.MessageBoxIcon.Information); return;

            case 4: FineUI.Alert.ShowInParent("订单已引入,无法进行核准", FineUI.MessageBoxIcon.Information); return;

            default: FineUI.Alert.ShowInParent("订单状态有误,无法核准", FineUI.MessageBoxIcon.Information); return;
            }

            ddlStatus.SelectedValue = model.STATUS.ToString();

            string result = DetailEdit();

            if (String.IsNullOrEmpty(result))
            {
                result = MAINEdit();
            }
            if (!String.IsNullOrEmpty(result))
            {
                FineUI.Alert.ShowInParent(result, FineUI.MessageBoxIcon.Error);
            }
            else
            {
                FineUI.Alert.ShowInParent("保存成功", FineUI.MessageBoxIcon.Error);
            }

            LoadMAIN();
            LoadDETAIL();
            //FineUI.Alert.ShowInParent(result, FineUI.MessageBoxIcon.Error);
            //FineUI.Alert.ShowInParent("核准成功", FineUI.MessageBoxIcon.Information);
        }
コード例 #4
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.PREPARE00</returns>
        public DataAccess.Model.PREPARE00 GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.PREPARE00           model      = null;
                Expression <Func <PREPARE00, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "SHOP_ID":
                    model      = list.SingleOrDefault(x => x.SHOP_ID == (string)value);
                    expression = x => x.SHOP_ID == (string)value;
                    break;

                case "PREPAR_ID":
                    model      = list.SingleOrDefault(x => x.PREPAR_ID == (string)value);
                    expression = x => x.PREPAR_ID == (string)value;
                    break;

                case "STATUS":
                    model      = list.SingleOrDefault(x => x.STATUS == (int)value);
                    expression = x => x.STATUS == (int)value;
                    break;

                case "INPUT_DATE":
                    model      = list.SingleOrDefault(x => x.INPUT_DATE == (DateTime)value);
                    expression = x => x.INPUT_DATE == (DateTime)value;
                    break;

                case "PRE_TYPE":
                    model      = list.SingleOrDefault(x => x.PRE_TYPE == (int)value);
                    expression = x => x.PRE_TYPE == (int)value;
                    break;

                case "STOCK_ID":
                    model      = list.SingleOrDefault(x => x.STOCK_ID == (string)value);
                    expression = x => x.STOCK_ID == (string)value;
                    break;

                case "USER_ID":
                    model      = list.SingleOrDefault(x => x.USER_ID == (string)value);
                    expression = x => x.USER_ID == (string)value;
                    break;

                case "APP_USER":
                    model      = list.SingleOrDefault(x => x.APP_USER == (string)value);
                    expression = x => x.APP_USER == (string)value;
                    break;

                case "APP_DATETIME":
                    model      = list.SingleOrDefault(x => x.APP_DATETIME == (DateTime)value);
                    expression = x => x.APP_DATETIME == (DateTime)value;
                    break;

                case "RELATE_ID":
                    model      = list.SingleOrDefault(x => x.RELATE_ID == (string)value);
                    expression = x => x.RELATE_ID == (string)value;
                    break;

                case "Memo":
                    model      = list.SingleOrDefault(x => x.Memo == (string)value);
                    expression = x => x.Memo == (string)value;
                    break;

                case "LOCKED":
                    model      = list.SingleOrDefault(x => x.LOCKED == (bool)value);
                    expression = x => x.LOCKED == (bool)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "Trans_STATUS":
                    model      = list.SingleOrDefault(x => x.Trans_STATUS == (bool)value);
                    expression = x => x.Trans_STATUS == (bool)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = PREPARE00.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取PREPARE00表记录时出现异常", e);

                return(null);
            }
        }