Beispiel #1
0
        public DTOResponse SaveSysparams(BasicRequest request)
        {
            DTOResponse dtoResponse = new DTOResponse();

            try
            {
                SysParams entity = HelperSerializer.GetObjectFromJsonString <SysParams>(request.PostData);
                if (entity == null)
                {
                    throw new Exception("传入的参数无法解析!");
                }

                using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection())
                {
                    SqlExpression <SysParams> expression1 = dbConn.From <SysParams>();
                    expression1.Where(x => x.ID == entity.ID);
                    expression1.UpdateFields.Add("PARAVALUE");

                    int count1 = dbConn.UpdateOnly <SysParams>(entity, expression1);
                    dtoResponse.TotalCount = count1;
                    dtoResponse.IsSuccess  = count1 == 1 ? true : false;

                    //dtoResponse.IsSuccess = dbConn.Update<SysParams>(entity);
                    dtoResponse.MessageText = "操作完成:" + dtoResponse.IsSuccess;
                    return(dtoResponse);
                }
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                logger.Error((object)ex);
                return(dtoResponse);
            }
        }
Beispiel #2
0
        public DTOResponse Save(ProductRequest request)
        {
            DTOResponse dtoResponse = new DTOResponse();

            try
            {
                if (string.IsNullOrEmpty(request.PostData))
                {
                    throw new Exception("传入的参数为空!");
                }
                long count = 0;
                using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection())
                {
                    //获取对象值
                    request.Entity = HelperSerializer.GetObjectFromJsonString <ProductEntity>(request.PostData);

                    if (request.ACTION == OPAction.CREATE)
                    {
                        ProductEntity entity = new ProductEntity();
                        entity.PRODUCTNO   = request.Entity.PRODUCTNO;
                        entity.PRODUCTNAME = request.Entity.PRODUCTNAME;
                        //entity.PRODUCTDESC = "";
                        //entity.PRODUCTSUBDESC = "";
                        //entity.PRODUCTSPEC = "";
                        entity.PRODUCTBARCODE = "0";
                        //entity.PRODUCTNODECODE = "";
                        entity.TURNOVERRATE    = "";
                        entity.ABC             = request.Entity.ABC;
                        entity.PRODUCTCLASS    = "";
                        entity.PRODUCTTYPE     = request.Entity.PRODUCTTYPE;
                        entity.PRODUCTTSTATE   = "1";
                        entity.QUANTITY_PACK   = request.Entity.QUANTITY_PACK;
                        entity.MAINUNIT        = request.Entity.MAINUNIT;
                        entity.BASICUNIT       = request.Entity.MAINUNIT;
                        entity.MAINTOBASICRATE = 1;
                        //entity.MAINTOBASICDESC = "";
                        entity.CREATEBY   = SysInfo.GetCurrentUserInfo();
                        entity.CREATEDATE = Utils.GetDatetime();
                        entity.MODIFYBY   = "";
                        entity.MODIFYDATE = "";
                        entity.REMARK     = request.Entity.REMARK;

                        /*entity.BRANDID = "";
                         * entity.BRANDNAME = "";
                         * entity.VENDORID = "";
                         * entity.VENDORNAME = "";
                         * entity.PRODUCTERID = "";
                         * entity.PRODUCTERNAME = "";
                         * entity.MARKETPRICE = "";
                         * entity.LOWESTSALEPRICE = "";
                         * entity.SELLPRICE = "";
                         * entity.ISDELICATE = "";
                         * entity.IMPORTPRODUCT = "";
                         * entity.IMAGEURL = "";
                         * entity.DEFAULTCOLOR = "";
                         * entity.PALLETEMPLTY = "";
                         * entity.PALLETENTITY = "";
                         * entity.SIZE_LENGTH = "";
                         * entity.SIZE_WIDTH = "";
                         * entity.SIZE_HEIGHT = "";
                         * entity.VOLUME = "";
                         * entity.WEIGHT = "";
                         * entity.NETWEIGHT = "";
                         * entity.WARNSTATE = "";
                         * entity.INV_HIGH = "";
                         * entity.INV_SAFE = "";
                         * entity.INV_ORDER = "";
                         * entity.INV_HIVEDAYS = "";
                         * entity.INV_LIMIT = "";
                         * entity.INV_HIGH_COLOR = "";
                         * entity.INV_SAFE_COLOR = "";
                         * entity.INV_ORDER_COLOR = "";
                         * entity.INV_HIVEDAYS_COLOR = "";
                         * entity.INV_LIMIT_COLOR = "";
                         * entity.CUSTOMCOL01 = "";
                         * entity.CUSTOMCOL02 = "";
                         * entity.CUSTOMCOL03 = "";
                         * entity.CUSTOMCOL04 = "";
                         * entity.CUSTOMCOL05 = "";
                         * entity.CUSTOMCOL06 = "";
                         * entity.CUSTOMCOL07 = "";
                         * entity.CUSTOMCOL08 = "";
                         * entity.CUSTOMCOL09 = "";
                         * entity.CUSTOMCOL10 = "";*/

                        //插入记录
                        count = dbConn.Insert <ProductEntity>(entity);
                    }
                    else if (request.ACTION == OPAction.UPDATE)
                    {
                        //更新记录
                        count = dbConn.SaveAll <ProductEntity>(new List <ProductEntity>()
                        {
                            request.Entity
                        });
                    }
                    else if (request.ACTION == OPAction.OP_01)
                    {
                        SqlExpression <ProductEntity> sqlExpression = dbConn.From <ProductEntity>();
                        sqlExpression.Where(x => x.ID == request.Entity.ID);
                        sqlExpression.UpdateFields.Add("DEFAULTCOLOR");
                        sqlExpression.UpdateFields.Add("PRODUCTTSTATE");

                        //更新记录
                        count = dbConn.UpdateOnly <ProductEntity>(request.Entity, sqlExpression);
                    }

                    dtoResponse.IsSuccess   = true;
                    dtoResponse.MessageText = "操作成功!" + count;
                    return(dtoResponse);
                }
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                logger.Error((object)ex);
                return(dtoResponse);
            }
        }
Beispiel #3
0
        public DTOResponse Save(PlanDetailRequest request)
        {
            DTOResponse dtoResponse = new DTOResponse();

            try
            {
                if (string.IsNullOrEmpty(request.PostData))
                {
                    throw new Exception("传入的参数为空!");
                }
                long count = 0;
                using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection())
                {
                    //获取对象值
                    request.Entity = HelperSerializer.GetObjectFromJsonString <PlanDetailEntity>(request.PostData);

                    if (request.ACTION == OPAction.CREATE)
                    {
                        ProductEntity productEntity = dbConn.Single <ProductEntity>(x => x.PRODUCTNO == request.Entity.PRODUCTNO);
                        if (productEntity == null)
                        {
                            throw new Exception("物料" + request.Entity.PRODUCTNO + "不存在!");
                        }

                        //获取计划序号
                        SysSequenceResult sequenceResult =
                            SysSequenceInstance.Instance().GetSysSequence("PLANID");

                        PlanDetailEntity entity = new PlanDetailEntity();
                        entity.PLANID     = long.Parse(sequenceResult.SEQVALUE);
                        entity.PLANNO     = sequenceResult.SEQVALUE + "#" + request.Entity.PLANNO;
                        entity.PLANTYPE   = request.Entity.PLANTYPE;
                        entity.LINENUM    = 1;
                        entity.LINESTATE  = 0;
                        entity.BPNO       = request.Entity.BPNO;
                        entity.BPNAME     = request.Entity.BPNAME;
                        entity.STATIONNO  = request.Entity.STATIONNO;
                        entity.MODIFYBY   = SysInfo.GetCurrentUserInfo();
                        entity.MODIFYDATE = Utils.GetTodayDateTimeNow();

                        /*entity.BOMID = "";
                         * entity.BOMNO = "";
                         * entity.BOMNAME = "";
                         * entity.BOMBATCHNO = "";*/
                        entity.PRODUCTID    = productEntity.ID;
                        entity.PRODUCTNO    = productEntity.PRODUCTNO;
                        entity.PRODUCTNAME  = productEntity.PRODUCTNAME;
                        entity.PRODUCTSPEC  = productEntity.PRODUCTSPEC;
                        entity.PRODUCTCLASS = productEntity.PRODUCTCLASS;
                        entity.PRODUCTTYPE  = productEntity.PRODUCTTYPE;
                        entity.BATCHNO      = request.Entity.BATCHNO;
                        entity.Q01          = request.Entity.Q01;
                        entity.Q02          = 0;
                        entity.Q03          = 0;
                        entity.Q04          = 0;
                        entity.Q05          = request.Entity.Q05;
                        entity.Q06          = request.Entity.Q06;
                        entity.MAINUNIT     = productEntity.MAINUNIT;
                        entity.BASICUNIT    = productEntity.MAINUNIT;
                        entity.REMARK1      = request.Entity.REMARK1;
                        entity.P01          = request.Entity.P01;
                        entity.P02          = request.Entity.P02;

                        /*entity.REMARK2 = "";
                         *
                         * entity.P03 = "";
                         * entity.P04 = "";
                         * entity.P05 = "";
                         * entity.P06 = "";
                         * entity.P07 = "";
                         * entity.P08 = "";
                         * entity.P09 = "";
                         * entity.P10 = "";
                         * entity.P11 = "";
                         * entity.P12 = "";
                         * entity.P13 = "";
                         * entity.P14 = "";
                         * entity.P15 = "";
                         * entity.P16 = "";
                         * entity.P17 = "";
                         * entity.P18 = "";
                         * entity.P19 = "";
                         * entity.P20 = "";*/

                        //插入记录
                        count = dbConn.Insert <PlanDetailEntity>(entity);
                    }
                    else if (request.ACTION == OPAction.UPDATE)
                    {
                        //更新记录
                        count = dbConn.SaveAll <PlanDetailEntity>(new List <PlanDetailEntity>()
                        {
                            request.Entity
                        });
                    }

                    dtoResponse.IsSuccess   = true;
                    dtoResponse.MessageText = "操作成功!" + count;
                    return(dtoResponse);
                }
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                logger.Error((object)ex);
                return(dtoResponse);
            }
        }