Example #1
0
        /// <summary>
        /// Read a phonebook entry in the current phonebook memory storage.  
        /// </summary>
        /// <param name="memory">Phonebook memory storage. see PhoneBookMemoryStorage.</param> 
        /// <param name="fromIndex">First entry location (or range of locations) where to read phonebook entry.</param>
        /// <param name="toIndex">Last entry location (or range of locations) where to read phonebook entry.</param>
        public BaseResult<GenericTypeResult<List<PhoneNumberInfo>>> ReadPhoneBook(string memory, int fromIndex, int toIndex)
        { 
            string response; 
            string command = fromIndex.ToString();
            BaseResult<GenericTypeResult<List<PhoneNumberInfo>>> ret = new BaseResult<GenericTypeResult<List<PhoneNumberInfo>>>();
            Stopwatch s = new Stopwatch();
             
            if (toIndex > 0)
            {
                command += "," + toIndex;
            }
            s.Start();
            if (!string.IsNullOrEmpty(memory))
            {
                response = Connection.Connector.Execute(Command.Set(Commands.CPBS, (char)34 + memory + (char)34));
            }
            response = Connection.Connector.Execute(Command.Set(Commands.CPBR, command));
            s.Stop();

            Regex regex = new Regex(@"\+CPBR: " + "(\\d+),\"(.+)\",(\\d+),\"(.+)\".*");
            List<PhoneNumberInfo> info = new List<PhoneNumberInfo>();
            for (Match match = regex.Match(response); match.Success; match = match.NextMatch())
            {
                info.Add(new PhoneNumberInfo() 
                {
                    Index = Convert.ToInt32(match.Groups[1].Value),
                    Memory = memory,
                    PhoneNumber = match.Groups[2].Value,
                    Name = match.Groups[4].Value
                });
            }
            ret.Response.Result = info;
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #2
0
        /// <summary>
        /// This command returns phonebook entries with alphanumeric fields starting with a given pattern. 
        /// </summary>
        /// <param name="memory">Phonebook memory storage. see PhoneBookMemoryStorage.</param>
        /// <param name="name">Searched pattern string (depends on the format of data stored in the phonebooks)</param> 
        public BaseResult<GenericTypeResult<List<PhoneNumberInfo>>> FindPhoneBook(string memory, string name)
        { 
            string response;
            BaseResult<GenericTypeResult<List<PhoneNumberInfo>>> ret = new BaseResult<GenericTypeResult<List<PhoneNumberInfo>>>();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connection.Connector.Execute(Command.Set(Commands.CPBS, (char)34 + memory + (char)34));
            response = Connection.Connector.Execute(Command.Set(Commands.CPBF, (char)34 + name + (char)34));
            s.Stop();

            Regex regex = new Regex(@"\+CPBF: " + "(\\d+),\"(.+)\",(\\d+),\"(.+)\".*\\r\\n");
            List<PhoneNumberInfo> info = new List<PhoneNumberInfo>();
            for (Match match = regex.Match(response); match.Success; match = match.NextMatch())
            {
                info.Add(new PhoneNumberInfo()
                {
                    Index = Convert.ToInt32(match.Groups[1].Value),
                    Memory = memory,
                    PhoneNumber = match.Groups[2].Value,
                    Name = match.Groups[4].Value
                });
            }
            ret.ExecutionTime = s.Elapsed;
            ret.Response.Result = info;
            return ret;
        }
Example #3
0
    public static void Main(string[] args)
    {
        var br = new BaseResult();
        var dr = new DerivedResult();

        var bas = new Base();
        var derived = new Derived();

        bas.Method();
        bas.MethodWithParameter1(br);
        bas.MethodWithParameter1(dr);
        bas.MethodWithParameter2(dr);

        bas = derived;
        bas.Method();
        bas.MethodWithParameter1(br);
        bas.MethodWithParameter1(dr);
        bas.MethodWithParameter2(dr);

        derived.Method();
        derived.MethodWithParameter1(br);
        derived.MethodWithParameter1(dr);
        derived.MethodWithParameter2(br);
        derived.MethodWithParameter2(dr);
    }
        public void ResultTest()
        {
            var result = new BaseResult(ResultLevel.ERROR, "test base result");

            Assert.NotNull(result);
            Assert.AreEqual(ResultLevel.ERROR, result.Level);
            Assert.AreEqual("test base result", result.Message);
        }
Example #5
0
 /// <summary>
 /// Dial a telephone number.
 /// After issuing this command, the modem will attempt to establish a connection and dial the number n. 
 /// </summary>
 /// <param name="number">The telephone number to be dialed. </param> 
 public BaseResult<GenericTypeResult<string>> Dial(string number)
 {
     BaseResult<GenericTypeResult<string>> response = new BaseResult<GenericTypeResult<string>>();
     string responseD;
     Stopwatch s = new Stopwatch();
     s.Start();
     responseD = Connection.Connector.Execute(Commands.AT + Commands.D + number + ";", delayWhenRead:5000);
     s.Stop();
     response.Response.Result = responseD;
     response.ExecutionTime = s.Elapsed;
     return response;
 }
Example #6
0
 public IHttpActionResult GetMessage([FromUri] string batch)
 {
     var result = new BaseResult();
     result.ResultCode = "1";
     result.ResultMessage = "Error";
     var list = new MessageDAL().GetListByBatch(batch);
     if (list.Any())
     {
         result.ResultCode = "1";
         result.ResultMessage = "Success";
         result.ResultData = list;
     }
     return Ok(result);
 }
Example #7
0
 /// <summary>
 /// Answer incoming call
 /// </summary>
 public BaseResult<GenericTypeResult<bool>> Answer()
 {
     BaseResult<GenericTypeResult<bool>> response = new BaseResult<GenericTypeResult<bool>>();
     string responseD;
     Stopwatch s = new Stopwatch();
     s.Start();
     responseD = Connection.Connector.Execute(Commands.A); 
     s.Stop();
     if (responseD.Contains(Commands.RESULT_OK))
     {
         response.Response.Result = true;
     }
     response.ExecutionTime = s.Elapsed;
     return response;   
 }
Example #8
0
        /// <summary>
        /// Delete All messages.
        /// </summary>
        /// <returns>return true if OK, otherwise false</returns>
        public BaseResult<GenericTypeResult<bool>> DeleteAll()
        { 
            string response = "";
            BaseResult<GenericTypeResult<bool>> ret = new BaseResult<GenericTypeResult<bool>>();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connection.Connector.Execute(Command.Set(Commands.CMGD, "1, 4"));
            s.Stop();

            if (response.Contains("OK"))
            {
                ret.Response.Result = true;
            }
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
        public void AssertExtractedFailDataset()
        {
            var mockDataSourceLocation = new Mock<IDataSourceLocation>();
            var dataSet = new ExtractedDataset<int>(ResultLevel.FATAL);

            var baseResult = new BaseResult(ResultLevel.FATAL, "Base result message");
            var parsingResult = new ParsingResult(ResultLevel.ERROR, "Parsing result", 123, mockDataSourceLocation.Object);

            dataSet.AddParsingResult(baseResult);
            dataSet.AddParsingResult(parsingResult);

            Assert.False(dataSet.IsExtractedSuccess);
            Assert.AreEqual(ResultLevel.FATAL, dataSet.ThresholdLevel);

            var entities = dataSet.ExtractedEntities;

            Assert.Null(entities);

        }
Example #10
0
        public IHttpActionResult KeyWordNearByStadium([FromUri] string key)
        {
            var result = new BaseResult();
            result.ResultCode = "1";
            result.ResultMessage = "Error";
            List<Stadium> nearby = new StadiumDAL().GetListByKeyWord(key);

            if (nearby.Any())
            {
                result.ResultData = nearby;
                result.ResultMessage = "Success";
                result.ResultCode = "0";
            }
            else
            {
                result.ResultMessage = "未找到数据";
            }
            return Ok(result);
        }
        public bool DelContactByGroup(List<int> contactIds, int groupId)
        {
            var cm = new ContactorManager();
                var ls = new List<Contactor>();

                if (contactIds.Count()>0)
                    ls.AddRange(contactIds.Select(item => new Contactor() { ContactorID = item }));

                BaseResult br = new BaseResult();
                if (groupId == 0)
                {
                    br = cm.DelContactors(LoginInfo.UserID, ls, LoginInfo.CompID);
                }
                else
                {
                    br = cm.DelContactorsByGroup(LoginInfo.UserID, ls, LoginInfo.CompID, groupId);
                }
                return br.State;
        }
Example #12
0
 public IHttpActionResult NearByStadium([FromUri] double lng, [FromUri] double lat, [FromUri] double distance, [FromUri] string keyword)
 {
     var result = new BaseResult();
     result.ResultCode = "1";
     result.ResultMessage = "Error";
     var sta = new StadiumDAL().GetList();
     List<Stadium> nearby = new List<Stadium>();
     if (sta.Any())
     {
         nearby = sta.Where(a => Distance.GetDistance(a.Latitude, a.Longitude, lat, lng) <= distance).ToList();
     }
     if (!keyword.IsNullOrWhiteSpace())
     {
         nearby = nearby.Where(a => a.Name.Contains(keyword) || a.Address.Contains(keyword)).ToList();
     }
     if (nearby.Any())
     {
         result.ResultData = nearby.Select(a => new
         {
             Id = a.Id,
             CreateTime = a.CreateTime,
             UpdateTime = a.UpdateTime,
             OperationUser = a.OperationUser,
             Status = a.Status,
             Version = a.Version,
             Name = a.Name,
             Address = a.Address,
             OpenStartTime = a.OpenStartTime.HasValue?a.OpenStartTime.Value.ToString("HH:mm"):"",
             OpenEndTime = a.OpenEndTime.HasValue ? a.OpenEndTime.Value.ToString("HH:mm") : "",
             Price = a.Price,
             Phone = a.Phone,
             Longitude = a.Longitude,
             Latitude = a.Latitude,
         });
         result.ResultMessage = "Success";
         result.ResultCode = "0";
     }
     else
     {
         result.ResultMessage = "未找到数据";
     }
     return Ok(result);
 }
        public void AssertExtractedSuccessDataset()
        {
            var mockDataSourceLocation = new Mock<IDataSourceLocation>();
            var dataSet = new ExtractedDataset<int>(ResultLevel.ERROR);

            var baseResult = new BaseResult(ResultLevel.INFO, "Base result message");
            var parsingResult = new ParsingResult(ResultLevel.INFO, "Parsing result", 123, mockDataSourceLocation.Object);

            dataSet.AddParsingResult(baseResult);
            dataSet.AddParsingResult(parsingResult);

            Assert.True(dataSet.IsExtractedSuccess);
            Assert.AreEqual(ResultLevel.ERROR, dataSet.ThresholdLevel);

            var entities = dataSet.ExtractedEntities;

            Assert.AreEqual(1, entities.Count());
            Assert.AreEqual(123, (int)entities.First());

        }
Example #14
0
 public IHttpActionResult GetMessage([FromUri] Guid UserId)
 {
     var result = new BaseResult();
     result.ResultCode = "1";
     result.ResultMessage = "Error";
     var list = new MessageDAL().GetListByUserId(UserId).OrderBy(a => a.CreateTime).ThenBy(a => a.MessageBatch);
     if (list.Any())
     {
         result.ResultCode = "0";
         result.ResultMessage = "Success";
         result.ResultData = list.Select(a => new
         {
             Batch = a.MessageBatch,
             FromWho = new CommonUserDAL().GetSingleById(a.FromWho.Value).NickName,
             ToWho = new CommonUserDAL().GetSingleById(a.ToWho.Value).NickName,
             CreateTime = a.CreateTime.Value.ToString("yyyy-MM-dd"),
             Text = a.Text
         });
     }
     return Ok(result);
 }
Example #15
0
        /// <summary>
        /// Returns Mapped Hotel Details view Model
        /// </summary>
        /// <param name="hoteldata"></param>
        /// <returns> Mapped Hotel Details view Model</returns>
        public static HotelDetailsViewModel MapHotelDetailsToHotelDetailsViewModel(BaseResult <List <HotelView> > hotelView)
        {
            HotelDetailsViewModel hotel = new HotelDetailsViewModel();

            foreach (var item in hotelView.Result)
            {
                if (!(hotel.HotelId == item.HotelId))
                {
                    hotel.HotelCode                    = item.HotelCode;
                    hotel.Location                     = item.CityName + ", " + item.CountryName;
                    hotel.HotelId                      = item.HotelId;
                    hotel.IsActive                     = item.IsActive;
                    hotel.HotelName                    = item.HotelName;
                    hotel.HotelChainId                 = item.HotelChainId;
                    hotel.HotelBrandId                 = item.HotelBrandId;
                    hotel.HotelTypeId                  = item.HotelTypeId;
                    hotel.CountryId                    = item.CountryId;
                    hotel.CityId                       = item.CityId;
                    hotel.Latitude                     = item.Latitude;
                    hotel.Longitude                    = item.Longitude;
                    hotel.ShortDescription             = item.ShortDescription;
                    hotel.LongDescription              = item.LongDescription;
                    hotel.Website                      = item.Website;
                    hotel.ReservationEmail             = item.ReservationEmail;
                    hotel.ReservationContactNo         = item.Telephone;
                    hotel.Address1                     = item.Address1;
                    hotel.Address2                     = item.Address2;
                    hotel.ZipCode                      = item.ZipCode;
                    hotel.IsExtranetAccess             = item.IsExtranetAccess;
                    hotel.IsChannelManagerConnectivity = item.IsChannelManagerConnectivity;
                    hotel.ChannelManagerId             = item.ChannelManagerId;

                    if (item.ChannelManagerId == 0)
                    {
                        hotel.ChannelManagerId = null;
                    }
                    ;
                    hotel.TotalNumberOfRooms = item.TotalNumberOfRooms;
                    hotel.StarRatingId       = item.StarRatingID;
                    hotel.MGPoint            = item.MGPoint;

                    DateTime dt;

                    if (item.CheckInFrom != null)
                    {
                        dt = new DateTime() + item.CheckInFrom;

                        hotel.CheckInFrom = dt.ToString("hh:mm tt");
                    }
                    //if (item.CheckInTo != null)
                    //{
                    //    dt = new DateTime() + (TimeSpan)item.CheckInTo;
                    //    hotel.CheckInTo = dt.ToString("hh:mm tt");
                    //}
                    //if (item.CheckOutFrom != null)
                    //{
                    //    dt = new DateTime() + (TimeSpan)item.CheckOutFrom;
                    //    hotel.CheckOutFrom = dt.ToString("hh:mm tt");
                    //}
                    if (item.CheckOutTo != null)
                    {
                        dt = new DateTime() + (TimeSpan)item.CheckOutTo;
                        hotel.CheckOutTo = dt.ToString("hh:mm tt");
                    }
                }

                if (!(hotel.ContactDetails.AsEnumerable().Where(id => id.ContactId == item.ContactId).Count() > 0))
                {
                    ContactDetailsViewModel contacts = new ContactDetailsViewModel
                    {
                        HotelId       = item.HotelId,
                        ContactId     = item.ContactId,
                        IsPrimary     = item.IsPrimary,
                        ContactPerson = item.ContactPerson,
                        DesignationId = item.DesignationId,
                        EmailAddress  = item.ContactEmailAddress,
                        ContactNumber = item.ContactNumber
                    };

                    hotel.ContactDetails.Add(contacts);
                }

                if (!(hotel.TaxDetails.AsEnumerable().Where(id => id.TaxTypeId == item.TaxTypeId && id.TaxApplicabilityId == item.TaxApplicabilityId).Count() > 0))
                {
                    HotelTaxRelationViewModel tax = new HotelTaxRelationViewModel
                    {
                        HotelId            = item.HotelId,
                        TaxTypeId          = item.TaxTypeId,
                        TaxesType          = item.TaxesType,
                        TaxApplicabilityId = item.TaxApplicabilityId,
#pragma warning disable CA1305 // Specify IFormatProvider
                        Amount = Convert.ToDecimal(item.TaxAmount),
#pragma warning restore CA1305 // Specify IFormatProvider
                        IsIncludedInRates = item.IsIncludedInRates
                    };

                    hotel.TaxDetails.Add(tax);
                }
                HotelPaymentMethodRelationViewModel payment = new HotelPaymentMethodRelationViewModel()
                {
                    HotelId = item.HotelId,
                    HotelPaymentMethodRelationId = item.HotelPaymentMethodRelationId,
                    PaymentMethodId = item.PaymentMethodId,
                    CurrencyId      = item.CurrencyId,
                    RateTypeId      = item.RateTypeId
                };
                hotel.HotelPaymentMethodRelation = payment;
            }

            return(hotel);
        }
Example #16
0
        /// <summary>
        /// Get the network operator.
        /// </summary>  
        public BaseResult<GenericTypeResult<string>> GetOperator()
        { 
            string response = "";
            const short maxLoop = 2;
            short loop = 0;
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();

            s.Start();  
            Connector.Execute(Command.Set(Commands.COPS, "3,0"));
            do
            {
                loop++;
                if (loop >= maxLoop) break;
                System.Threading.Thread.Sleep(500);            
                response = Connector.Execute(Command.Get(Commands.COPS)); 
                Match match = new Regex(@"\+COPS: (\d+),(\d+)," + "\"" + @"(.*[a-zA-Z0-9-_ ].*)" + "\"").Match(response);
                if (match.Success)
                {
                    response = match.Groups[3].Value;
                    this.Operator = response;
                    break;
                }
                else
                    response = "";
            }
            while (string.IsNullOrEmpty(response));
            s.Stop();
            ret.ExecutionTime = s.Elapsed;
            ret.Response.Result = response;

            this.Operator = response; 
            return ret;
        }
Example #17
0
        /// <summary>
        /// Returns information to identify the individual ME. Typically IMEI (International Mobile station Equipment Identity).
        /// </summary>  
        public BaseResult<GenericTypeResult<string>> GetSerialNumber()
        { 
            string response;
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connector.Execute(Command.ToString(Commands.CGSN));
            s.Stop();

            Match match = new Regex(@"\+CGSN\r\r(\d+)").Match(response);
            if (match.Success)
            { 
                response = match.Groups[1].Value; 
            }
            ret.ExecutionTime = s.Elapsed;
            ret.Response.Result = response;

            return ret; 
        }
Example #18
0
 public CommonResponeModel setResult(BaseResult Result)
 {
     this.Result = Result;
     return(this);
 }
Example #19
0
        /// <summary>
        /// 检查是否符合充值设置的金额
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public BaseResult CheckCZMaxMoney(Hashtable param)
        {
            BaseResult br = new BaseResult();

            try
            {
                Tb_Hy_Detail hyDetailModel = new Tb_Hy_Detail();
                Hashtable    ht            = new Hashtable();
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("id_hy", param["id_hy"].ToString());
                ht.Add("bm_djlx", "HY020");
                var yczList = DAL.QueryList <Tz_Hy_Je_Flow>(typeof(Tz_Hy_Je_Flow), ht).ToList();

                decimal moneyMonthYCZ = 0;
                if (yczList != null && yczList.Count() > 0)
                {
                    moneyMonthYCZ = (decimal)yczList.Sum(d => d.je);
                }

                var shopParm    = GetShopParm(param["id_masteruser"].ToString(), param["id_shop"].ToString());
                var shopParmAll = GetShopParm(param["id_masteruser"].ToString(), "0");

                if (shopParm != null && shopParm.ContainsKey("success") && shopParm["success"].ToString() == "1")
                {
                    #region hy_czje_min_onec
                    var hy_czje_min_onec = shopParm["hy_czje_min_onec"].ToString();
                    if (!string.IsNullOrEmpty(hy_czje_min_onec) && CyVerify.IsNumeric(hy_czje_min_onec))
                    {
                        if (decimal.Parse(param["je"].ToString()) < decimal.Parse(hy_czje_min_onec))
                        {
                            br.Success = false;
                            br.Message.Add("操作失败:每次最小金额至少为: " + hy_czje_min_onec + "  ");
                            return(br);
                        }
                    }
                    else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1")
                    {
                        var hy_czje_min_onec_all = shopParmAll["hy_czje_min_onec"].ToString();
                        if (!string.IsNullOrEmpty(hy_czje_min_onec_all) && CyVerify.IsNumeric(hy_czje_min_onec_all))
                        {
                            if (decimal.Parse(param["je"].ToString()) < decimal.Parse(hy_czje_min_onec_all))
                            {
                                br.Success = false;
                                br.Message.Add("操作失败:每次充值金额最小为: " + hy_czje_min_onec_all + " ");
                                return(br);
                            }
                        }
                    }
                    #endregion

                    #region hy_czje_max_onec
                    var hy_czje_max_onec = shopParm["hy_czje_max_onec"].ToString();
                    if (!string.IsNullOrEmpty(hy_czje_max_onec) && CyVerify.IsNumeric(hy_czje_max_onec))
                    {
                        if (decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_onec))
                        {
                            br.Success = false;
                            br.Message.Add("操作失败:每次充值金额最大为: " + hy_czje_max_onec + "  ");
                            return(br);
                        }
                    }
                    else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1")
                    {
                        var hy_czje_max_onec_all = shopParmAll["hy_czje_max_onec"].ToString();
                        if (!string.IsNullOrEmpty(hy_czje_max_onec_all) && CyVerify.IsNumeric(hy_czje_max_onec_all))
                        {
                            if (decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_onec_all))
                            {
                                br.Success = false;
                                br.Message.Add("操作失败:每次充值金额最大为: " + hy_czje_max_onec_all + " ");
                                return(br);
                            }
                        }
                    }
                    #endregion

                    #region hy_czje_max_month
                    var hy_czje_max_month = shopParm["hy_czje_max_month"].ToString();
                    if (!string.IsNullOrEmpty(hy_czje_max_month) && CyVerify.IsNumeric(hy_czje_max_month))
                    {
                        if ((moneyMonthYCZ + decimal.Parse(param["je"].ToString())) > decimal.Parse(hy_czje_max_month))
                        {
                            br.Success = false;
                            br.Message.Add("操作失败:每月充值最大金额: " + hy_czje_max_month + "  本月已充值: " + moneyMonthYCZ + "  ");
                            return(br);
                        }
                    }
                    else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1")
                    {
                        var hy_czje_max_month_all = shopParmAll["hy_czje_max_month"].ToString();
                        if (!string.IsNullOrEmpty(hy_czje_max_month_all) && CyVerify.IsNumeric(hy_czje_max_month_all))
                        {
                            if (moneyMonthYCZ + decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_month_all))
                            {
                                br.Success = false;
                                br.Message.Add("操作失败:每月充值最大金额: " + hy_czje_max_month_all + "  本月已充值: " + moneyMonthYCZ + "  ");
                                return(br);
                            }
                        }
                    }
                    #endregion
                }
                else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1")
                {
                    #region hy_czje_min_onec  hy_czje_max_onec  hy_czje_max_month
                    var hy_czje_min_onec  = shopParm["hy_czje_min_onec"].ToString();
                    var hy_czje_max_onec  = shopParm["hy_czje_max_onec"].ToString();
                    var hy_czje_max_month = shopParm["hy_czje_max_month"].ToString();

                    if (!string.IsNullOrEmpty(hy_czje_min_onec) && CyVerify.IsNumeric(hy_czje_min_onec))
                    {
                        if (decimal.Parse(param["je"].ToString()) < decimal.Parse(hy_czje_min_onec))
                        {
                            br.Success = false;
                            br.Message.Add("操作失败:每次充值金额最小为: " + hy_czje_min_onec + "  ");
                            return(br);
                        }
                    }

                    if (!string.IsNullOrEmpty(hy_czje_max_onec) && CyVerify.IsNumeric(hy_czje_max_onec))
                    {
                        if (decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_onec))
                        {
                            br.Success = false;
                            br.Message.Add("操作失败:每次充值金额最大为: " + hy_czje_max_onec + "  ");
                            return(br);
                        }
                    }

                    if (!string.IsNullOrEmpty(hy_czje_max_month) && CyVerify.IsNumeric(hy_czje_max_month))
                    {
                        if ((moneyMonthYCZ + decimal.Parse(param["je"].ToString())) > decimal.Parse(hy_czje_max_month))
                        {
                            br.Success = false;
                            br.Message.Add("操作失败:每月充值最大金额: " + hy_czje_max_month + "  本月已充值: " + moneyMonthYCZ + "  ");
                            return(br);
                        }
                    }
                    #endregion
                }

                br.Success = true;
                return(br);
            }
            catch (Exception ex)
            {
                br.Success = false;
                br.Message.Add("操作失败:检查是否符合充值设置的金额获取到异常 ");
                return(br);
            }
        }
Example #20
0
        public ActionResult Add(Tb_Shopsp model)
        {
            BaseResult br       = new BaseResult();
            var        oldParam = new Hashtable();

            try
            {
                #region 获取参数
                Hashtable param = base.GetParameters();

                ParamVessel p = new ParamVessel();
                p.Add("shopspList", string.Empty, HandleType.ReturnMsg);  //商品List
                p.Add("dh", string.Empty, HandleType.ReturnMsg);
                p.Add("id_shop", string.Empty, HandleType.ReturnMsg);     //id_shop
                p.Add("rq", string.Empty, HandleType.ReturnMsg);          //rq
                //p.Add("rq_jh", string.Empty, HandleType.ReturnMsg);//rq_jh
                p.Add("flag_ddlx", string.Empty, HandleType.ReturnMsg);   //flag_ddlx
                p.Add("flag_dhtype", string.Empty, HandleType.ReturnMsg); //flag_dhtype
                p.Add("id_kh", string.Empty, HandleType.ReturnMsg);       //id_kh
                p.Add("id_jbr", string.Empty, HandleType.ReturnMsg);      //id_jbr
                p.Add("remark", string.Empty, HandleType.DefaultValue);   //remark
                p.Add("type", string.Empty, HandleType.Remove);           //type
                p.Add("id", string.Empty, HandleType.Remove);             //id

                param = param.Trim(p);
                param.Add("id_masteruser", id_user_master);
                param.Add("id_user", id_user);
                oldParam = (Hashtable)param.Clone();
                #endregion

                List <Td_Xs_Dd_2> shopspList = JSON.Deserialize <List <Td_Xs_Dd_2> >(param["shopspList"].ToString()) ?? new List <Td_Xs_Dd_2>();

                #region 验证数据
                if (shopspList == null || shopspList.Count() <= 0)
                {
                    br.Success = false;
                    br.Message.Add("商品不能为空!");
                    br.Level = ErrorLevel.Warning;
                    br.Data  = "shopspList";
                    return(base.JsonString(new
                    {
                        status = "error",
                        message = string.Join(";", br.Message)
                    }));
                }

                var digitHashtable = GetParm();
                foreach (var item in shopspList)
                {
                    item.sl = CySoft.Utility.DecimalExtension.Digit(item.sl, int.Parse(digitHashtable["sl_digit"].ToString()));
                    item.dj = CySoft.Utility.DecimalExtension.Digit(item.dj, int.Parse(digitHashtable["dj_digit"].ToString()));
                    item.je = CySoft.Utility.DecimalExtension.Digit(item.je, int.Parse(digitHashtable["je_digit"].ToString()));

                    if (item.sl == 0)
                    {
                        br.Success = false;
                        br.Message.Add("商品[" + item.barcode + "]数量不允许为0!");
                        br.Level = ErrorLevel.Warning;
                        br.Data  = "shopspList";
                        return(base.JsonString(new
                        {
                            status = "error",
                            message = string.Join(";", br.Message)
                        }));
                    }

                    //此处验证数据是否符合
                    var tempJe = CySoft.Utility.DecimalExtension.Digit(item.sl * item.dj, int.Parse(digitHashtable["je_digit"].ToString()));
                    var tempDj = CySoft.Utility.DecimalExtension.Digit(item.je / item.sl, int.Parse(digitHashtable["dj_digit"].ToString()));
                    if (tempJe == item.je || tempDj == item.dj)
                    {
                        continue;
                    }
                    else
                    {
                        br.Success = false;
                        br.Message.Add("商品中存在 单价*数量不等于金额的数据!");
                        return(base.JsonString(new
                        {
                            status = "error",
                            message = string.Join(";", br.Message)
                        }));
                    }
                }

                param.Remove("shopspList");
                param.Add("shopspList", shopspList);
                param.Add("DigitHashtable", digitHashtable);
                param.Add("autoAudit", AutoAudit());
                #endregion

                if (param.ContainsKey("type") && param["type"].ToString() == "edit")
                {
                    br = BusinessFactory.Td_Xs_Dd_1.Update(param);
                    WriteDBLog("销售订单-编辑", oldParam, br);
                }
                else
                {
                    //插入表
                    br = BusinessFactory.Td_Xs_Dd_1.Add(param);
                    WriteDBLog("销售订单-新增", oldParam, br);
                }

                if (br.Success)
                {
                    return(base.JsonString(new
                    {
                        status = "success",
                        message = string.Join(";", br.Message)
                    }));
                }
                else
                {
                    return(base.JsonString(br, 1));
                }
            }
            catch (CySoftException brEx)
            {
                br.Success = false;
                br.Data    = "";
                br.Message.Clear();
                br.Message.Add(brEx.Message.ToString());
                br.Level = ErrorLevel.Warning;
                WriteDBLog("销售订单-新增/编辑", oldParam, br);
                return(base.JsonString(new
                {
                    status = "error",
                    message = string.Join(";", br.Message)
                }));
            }
            catch (Exception ex)
            {
                br.Success = false;
                br.Data    = "";
                br.Message.Add("数据不符合要求!");
                br.Level = ErrorLevel.Warning;
                WriteDBLog("销售订单-新增/编辑", oldParam, br);
                return(base.JsonString(new
                {
                    status = "error",
                    message = string.Join(";", br.Message)
                }));
            }
        }
Example #21
0
        public BaseResult AddWork(dynamic entity)
        {
            #region 获取数据
            Hashtable  param = (Hashtable)entity;
            BaseResult br    = new BaseResult();
            Hashtable  ht    = new Hashtable();
            #endregion

            #region 验证参数
            if (!param.ContainsKey("Type") || string.IsNullOrEmpty(param["Type"].ToString()))
            {
                br.Success = false;
                br.Message.Add("业务数据异常!");
                return(br);
            }

            if (decimal.Parse(param["je"].ToString()) == 0)
            {
                br.Success = false;
                br.Message.Add("操作金额不能等于0!");
                return(br);
            }
            #endregion

            if (param["Type"].ToString() == "CZ")
            {
                #region 充值
                #region 检查会员是否有效
                br = base.CheckHY(param);
                if (!br.Success)
                {
                    throw new CySoftException(br);
                }
                Tb_Hy_Detail hy_detail = (Tb_Hy_Detail)br.Data;
                #endregion
                #region 检查是否符合充值设置的金额
                if (decimal.Parse(param["je"].ToString()) > 0)
                {
                    br = this.CheckCZMaxMoney(param);
                    if (!br.Success)
                    {
                        throw new CySoftException(br);
                    }
                }
                #endregion
                #region 获取赠送金额等信息
                hy_detail.Tb_Hy_Shop.id_shop = param["id_shop"].ToString();
                var     czrule_zssp_list = new List <Tb_Hy_Czrule_Zssp_Api_Query>();
                decimal je_zs            = GetJe_Qm_Zs(hy_detail, decimal.Parse(param["je"].ToString()), ref czrule_zssp_list);
                string  dh     = GetNewDH(param["id_masteruser"].ToString(), param["id_shop"].ToString(), Enums.FlagDJLX.DHCZ);
                string  dh_pay = "";
                if (param.ContainsKey("dh") && !string.IsNullOrEmpty(param["dh"].ToString()))
                {
                    dh = param["dh"].ToString();
                }
                if (param.ContainsKey("dh_pay") && !string.IsNullOrEmpty(param["dh_pay"].ToString()))
                {
                    dh_pay = param["dh_pay"].ToString();
                }
                string  id    = GetGuid;
                decimal je_ye = 0;
                #endregion
                #region 更新/插入Tz_Hy_Je表
                ht.Clear();
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_hy", param["id_hy"].ToString());
                var brJe = this.GetOne(ht);
                if (!brJe.Success)
                {
                    throw new CySoftException(br);
                }
                else
                {
                    var dbJeModel = (Tz_Hy_Je)brJe.Data;
                    if (dbJeModel != null && !string.IsNullOrEmpty(dbJeModel.id))
                    {
                        #region 更新数据
                        if (RecordKeyError(dbJeModel))
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add("会员金额数据非法!");
                            throw new CySoftException(br);
                        }
                        else if (ZBError(dbJeModel))
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add("会员金额账本数据非法!");
                            throw new CySoftException(br);
                        }
                        else
                        {
                            if (decimal.Parse(param["je"].ToString()) < 0 && (dbJeModel.je_qm + decimal.Parse(param["je"].ToString())) < 0)
                            {
                                br.Success = false;
                                br.Message.Clear();
                                br.Message.Add(String.Format("操作失败,账户余额(" + dbJeModel.je_qm + ") + 充值金额(" + decimal.Parse(param["je"].ToString()) + ")  不能为负!"));
                                throw new CySoftException(br);
                            }
                            je_ye               = (decimal)dbJeModel.je_qm + (decimal)dbJeModel.je_qm_zs;
                            dbJeModel.je_qm     = dbJeModel.je_qm + decimal.Parse(param["je"].ToString());
                            dbJeModel.je_qm_zs  = dbJeModel.je_qm_zs + je_zs;
                            dbJeModel.recodekey = GetRecordKey(dbJeModel);
                            DAL.Update(dbJeModel);
                        }
                        #endregion
                    }
                    else
                    {
                        #region 插入数据
                        Tz_Hy_Je addModel = new Tz_Hy_Je()
                        {
                            id_masteruser = param["id_masteruser"].ToString(),
                            id            = GetGuid,
                            id_hy         = param["id_hy"].ToString(),
                            je_qm         = 0,
                            je_qm_zs      = 0
                        };

                        if (ZBError(addModel))
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add("会员金额账本数据非法!");
                            throw new CySoftException(br);
                        }

                        if (decimal.Parse(param["je"].ToString()) < 0)
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add(String.Format("操作失败,账户余额(0) + 充值金额(" + decimal.Parse(param["je"].ToString()) + ")  不能为负!"));
                            throw new CySoftException(br);
                        }

                        addModel.je_qm     = decimal.Parse(param["je"].ToString());
                        addModel.je_qm_zs  = je_zs;
                        addModel.recodekey = GetRecordKey(addModel);
                        DAL.Add(addModel);
                        #endregion
                    }
                }
                #endregion
                #region 插入流水表
                ht.Clear();
                ht.Add("id", GetGuid);
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_bill", id);
                ht.Add("bm_djlx", "HY020");
                ht.Add("rq", DateTime.Parse(param["rq"].ToString()));
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("id_hy", param["id_hy"].ToString());
                ht.Add("je", decimal.Parse(param["je"].ToString()));
                ht.Add("je_zs", je_zs);
                ht.Add("bz", param["bz"].ToString());
                var addFlowNum = Tz_Hy_Je_FlowDAL.AddFlowWithExists(typeof(Tz_Hy_Je_Flow), ht);
                if (addFlowNum == 0)
                {
                    br.Success = false;
                    br.Message.Clear();
                    br.Message.Add(string.Format("充值单据已存在!"));
                    throw new CySoftException(br);
                }
                #endregion
                #region 插入表头
                ht.Clear();
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id", id);
                ht.Add("dh", dh);
                ht.Add("rq", DateTime.Parse(param["rq"].ToString()));
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("bm_djlx", "HY020");
                ht.Add("id_pay", param["id_pay"].ToString());
                ht.Add("id_jbr", param["id_create"].ToString());
                ht.Add("je_mxtotal", decimal.Parse(param["je"].ToString()));
                ht.Add("flag_sh", (byte)Enums.FlagSh.HadSh);
                ht.Add("flag_cancel", (byte)Enums.FlagCancel.NoCancel);
                ht.Add("bz", param["bz"].ToString());
                ht.Add("id_create", param["id_create"].ToString());
                ht.Add("flag_delete", (byte)Enums.FlagDelete.NoDelete);
                ht.Add("id_user_sh", param["id_create"].ToString());
                ht.Add("rq_sh", DateTime.Parse(param["rq"].ToString()));
                ht.Add("dh_pay", dh_pay);

                var addHeadNum = Td_Hy_Cz_1DAL.AddWithExists(typeof(Td_Hy_Cz_1), ht);
                if (addHeadNum == 0)
                {
                    br.Success = false;
                    br.Message.Clear();
                    br.Message.Add(string.Format("充值单据已存在!"));
                    throw new CySoftException(br);
                }
                #endregion
                #region 插入表体
                var td_Hy_Cz_2 = new Td_Hy_Cz_2()
                {
                    id_masteruser = param["id_masteruser"].ToString(),
                    id            = GetGuid,
                    id_hy         = param["id_hy"].ToString(),
                    id_bill       = id,
                    sort_id       = 1,
                    je            = decimal.Parse(param["je"].ToString()),
                    je_zs         = je_zs,
                    bz            = "接口充值",
                    rq_create     = DateTime.Now,
                    je_ye         = je_ye
                };
                DAL.Add(td_Hy_Cz_2);
                #endregion
                #region 读取充值后金额 并验证
                ht.Clear();
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_hy", param["id_hy"].ToString());
                var brJeNow = this.Get(ht);
                if (!brJeNow.Success)
                {
                    br.Success = false;
                    br.Message.Add(string.Format("操作失败 查询金额失败 !"));
                    throw new CySoftException(br);
                }
                else
                {
                    //回写 Td_Hy_Cz_2 的 je_ye 为当前的余额 目前取消掉了
                    var dbJeModel = (Tz_Hy_Je)brJeNow.Data;
                    //ht.Clear();
                    //ht.Add("id", td_Hy_Cz_2.id);
                    //ht.Add("id_masteruser", param["id_masteruser"].ToString());
                    //ht.Add("new_je_ye", dbJeModel.je_qm);
                    //DAL.UpdatePart(typeof(Td_Hy_Cz_2), ht);

                    if (ZBError(dbJeModel))
                    {
                        br.Success = false;
                        br.Message.Clear();
                        br.Message.Add("操作失败 会员金额账本数据非法 !");
                        throw new CySoftException(br);
                    }
                }
                #endregion
                #region 返回
                var jeNowModel = (Tz_Hy_Je)brJeNow.Data;
                br.Message.Add(String.Format("操作成功!"));
                br.Success = true;
                br.Data    = new { add_je = decimal.Parse(param["je"].ToString()), add_je_zs = je_zs, je_qm = jeNowModel.je_qm, je_qm_zs = jeNowModel.je_qm_zs, id = id, czrule_zssp = czrule_zssp_list };
                return(br);

                #endregion
                #endregion
            }
            else if (param["Type"].ToString() == "XF")
            {
                #region 消费

                #region 检查会员是否有效
                br = base.CheckHY(param);
                if (!br.Success)
                {
                    throw new CySoftException(br);
                }

                var tempModel = new Tz_Hy_Je()
                {
                    je_qm = decimal.Parse(param["je"].ToString()), je_qm_zs = 0
                };
                #endregion

                #region 验证会员金额是否非法 并更新账户以及插入流水帐
                ht.Clear();
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_hy", param["id_hy"].ToString());
                var brJe = this.GetOne(ht);
                if (!brJe.Success)
                {
                    throw new CySoftException(br);
                }
                else
                {
                    var dbJeModel = (Tz_Hy_Je)brJe.Data;
                    if (dbJeModel != null && !string.IsNullOrEmpty(dbJeModel.id))
                    {
                        #region 验证会员金额数据是否非法
                        if (RecordKeyError(dbJeModel))
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add("会员金额数据非法!");
                            throw new CySoftException(br);
                        }
                        #endregion
                        #region 验证会员金额账本数据是否非法
                        if (ZBError(dbJeModel))
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add("会员金额账本数据非法!");
                            throw new CySoftException(br);
                        }
                        #endregion
                        #region 插入流水表
                        tempModel = GetMonenyCost(decimal.Parse(param["je"].ToString()), dbJeModel);
                        ht.Clear();
                        ht.Add("id", GetGuid);
                        ht.Add("id_masteruser", param["id_masteruser"].ToString());
                        ht.Add("id_bill", param["id_bill"].ToString());
                        ht.Add("bm_djlx", param["bm_djlx"].ToString());
                        ht.Add("rq", DateTime.Parse(param["rq"].ToString()));
                        ht.Add("id_shop", param["id_shop"].ToString());
                        ht.Add("id_hy", param["id_hy"].ToString());
                        ht.Add("je", tempModel.je_qm * (-1));
                        ht.Add("je_zs", tempModel.je_qm_zs * (-1));
                        ht.Add("bz", param["bz"].ToString());
                        var addFlowNum = Tz_Hy_Je_FlowDAL.AddFlowForXFWithExists(typeof(Tz_Hy_Je_Flow), ht);
                        if (addFlowNum == 0)
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add("消费单据已存在!");
                            throw new CySoftException(br);
                        }

                        #endregion
                        #region 验证账户余额是否充足
                        if (dbJeModel.je_qm < tempModel.je_qm)
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add(String.Format("操作失败,正常账户余额(" + dbJeModel.je_qm + ") < 正常消费金额(" + tempModel.je_qm + ")!"));
                            throw new CySoftException(br);
                        }

                        if (dbJeModel.je_qm_zs < tempModel.je_qm_zs)
                        {
                            br.Success = false;
                            br.Message.Clear();
                            br.Message.Add(String.Format("操作失败,赠送账户余额(" + dbJeModel.je_qm_zs + ") < 赠送消费金额(" + tempModel.je_qm_zs + ")!"));
                            throw new CySoftException(br);
                        }
                        #endregion
                        #region 更新数据
                        dbJeModel.je_qm     = dbJeModel.je_qm - tempModel.je_qm;
                        dbJeModel.je_qm_zs  = dbJeModel.je_qm_zs - tempModel.je_qm_zs;
                        dbJeModel.recodekey = GetRecordKey(dbJeModel);
                        DAL.Update(dbJeModel);
                        #endregion
                    }
                    else
                    {
                        #region 操作失败 会员还未充值过
                        br.Success = false;
                        br.Message.Clear();
                        br.Message.Add(string.Format("操作失败 会员还未充值过!"));
                        throw new CySoftException(br);
                        #endregion
                    }
                }
                #endregion

                #region 查询消费后会员的金额
                ht.Clear();
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_hy", param["id_hy"].ToString());
                var brJeNow = this.Get(ht);
                if (!brJeNow.Success)
                {
                    br.Success = false;
                    br.Message.Clear();
                    br.Message.Add(string.Format("操作完毕 查询金额失败!"));
                    throw new CySoftException(br);
                }
                else
                {
                    var dbJeModel = (Tz_Hy_Je)brJeNow.Data;
                    if (ZBError(dbJeModel))
                    {
                        br.Success = false;
                        br.Message.Clear();
                        br.Message.Add("操作失败 会员金额账本数据非法 !");
                        throw new CySoftException(br);
                    }
                }
                #endregion

                #region 返回
                var jeNowModel = (Tz_Hy_Je)brJeNow.Data;
                br.Message.Add(String.Format("操作成功!"));
                br.Success = true;
                br.Data    = new { add_je = tempModel.je_qm, add_je_zs = tempModel.je_qm_zs, je_qm = jeNowModel.je_qm, je_qm_zs = jeNowModel.je_qm_zs };
                return(br);

                #endregion

                #endregion
            }
            else
            {
                #region 返回
                br.Message.Add(String.Format("操作失败,无此操作类型!"));
                br.Success = false;
                return(br);

                #endregion
            }
        }
Example #22
0
 public void MethodWithParameter2(BaseResult r1)
 {
     Console.WriteLine("Derived MethodWithParameter2");
 }
Example #23
0
 /// <summary>
 /// Get network registration
 /// </summary> 
 public BaseResult<GenericTypeResult<RegistrationStatus>> GetRegistrationStatus()
 {
     BaseResult<GenericTypeResult<RegistrationStatus>> ret = new BaseResult<GenericTypeResult<RegistrationStatus>>();
     Stopwatch s = new Stopwatch();
     s.Start();
     string response = Connector.Execute(Command.Get(Commands.CREG), delayWhenRead:3150);
     s.Stop();
     Match match = new Regex(@"\+CREG: (\d+),(\d+)").Match(response);
     if (match.Success)
     {
         ret.ExecutionTime = s.Elapsed;
         ret.Response.Result = (RegistrationStatus)(Convert.ToInt32(match.Groups[2].Value)); 
     } 
     return ret;
 }
Example #24
0
        public BaseResult ActiveWork(Hashtable param)
        {
            #region 参数验证
            BaseResult result = new BaseResult()
            {
                Success = true
            };
            if (param == null || param.Count < 3)
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            var id            = param["id"].ToString();
            var id_masteruser = param["id_masteruser"].ToString();
            var id_user       = param["id_user"].ToString();
            if (string.IsNullOrEmpty(id))
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            if (string.IsNullOrEmpty(id_masteruser) || string.IsNullOrEmpty(id_user))
            {
                result.Success = false;
                result.Message.Add("请登录!");
                return(result);
            }
            #endregion
            #region 更新数据
            Hashtable ht = new Hashtable();
            ht.Add("id", id);
            var brXs = this.Get(ht);
            if (!brXs.Success)
            {
                return(brXs);
            }
            else
            {
                #region 校验商品合法性
                Td_Xs_Dd_1_Query_DetailModel dbModel = (Td_Xs_Dd_1_Query_DetailModel)brXs.Data;
                if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id) || dbModel.body == null || dbModel.body.Count() <= 0)
                {
                    result.Success = false;
                    result.Message.Add("获取销售订单信息不符合要求!");
                    return(result);
                }

                ht.Clear();
                ht.Add("id_masteruser", id_masteruser);
                ht.Add("id", dbModel.head.id_shop);
                var tb_shop = DAL.GetItem <Tb_Shop>(typeof(Tb_Shop), ht);
                if (tb_shop == null || string.IsNullOrEmpty(tb_shop.id))
                {
                    result.Success = false;
                    result.Message.Add("获取送货门店信息失败!");
                    return(result);
                }

                ht.Clear();
                ht.Add("id_masteruser", id_masteruser);
                ht.Add("id_shop", dbModel.head.id_shop);
                var shopspList = DAL.QueryList <Tb_Shopsp>(typeof(Tb_Shopsp), ht);
                if (shopspList == null || shopspList.Count() <= 0)
                {
                    result.Success = false;
                    result.Message.Add("该送货门店下不存在商品!");
                    return(result);
                }



                var noShopspList = (from body in dbModel.body
                                    where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim()) == 0
                                    select body).ToList();
                if (noShopspList != null && noShopspList.Count > 0)
                {
                    ht.Clear();
                    ht.Add("id_masteruser", id_masteruser);
                    ht.Add("id", noShopspList.FirstOrDefault().id_shopsp);
                    var sp = DAL.GetItem <Tb_Shopsp>(typeof(Tb_Shopsp), ht);

                    result.Success = false;
                    if (sp != null && !string.IsNullOrEmpty(sp.id))
                    {
                        result.Message.Add(string.Format("审核失败,门店[{0}]不存在商品[{1}]", tb_shop.mc, sp.bm));
                    }
                    else
                    {
                        result.Message.Add(string.Format("审核失败,门店[{0}]不存在商品[{1}]", tb_shop.mc, noShopspList.FirstOrDefault().id_shopsp));
                    }
                    throw new CySoftException(result);
                }

                var stopShopspList = (from body in dbModel.body
                                      where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && d.flag_state == (byte)Enums.FlagShopspStop.Stoped) > 0
                                      select body).ToList();
                if (stopShopspList != null && stopShopspList.Count > 0)
                {
                    result.Success = false;
                    result.Message.Add(string.Format("审核失败,商品编码为[{0}]已停用!", shopspList.Where(d => d.id == stopShopspList.FirstOrDefault().id_shopsp).FirstOrDefault().bm));
                    throw new CySoftException(result);
                }

                var noSpflShopspList = (from body in dbModel.body
                                        where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && d.id_spfl == "0") > 0
                                        select body).ToList();
                if (noSpflShopspList != null && noSpflShopspList.Count > 0)
                {
                    result.Success = false;
                    result.Message.Add(string.Format("审核失败,商品编码为[{0}]未设置分类", shopspList.Where(d => d.id == noSpflShopspList.FirstOrDefault().id_shopsp).FirstOrDefault().bm));
                    throw new CySoftException(result);
                }


                var noId_kcspShopspList = (from body in dbModel.body
                                           where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && (d.id_kcsp == null || d.id_kcsp == "")) > 0
                                           select body).ToList();
                if (noId_kcspShopspList != null && noId_kcspShopspList.Count > 0)
                {
                    result.Success = false;
                    result.Message.Add(string.Format("审核失败,商品编码为[{0}] 库存ID 为空!", shopspList.Where(d => d.id == noId_kcspShopspList.FirstOrDefault().id_shopsp).FirstOrDefault().bm));
                    throw new CySoftException(result);
                }


                var noDwShopspList = (from body in dbModel.body
                                      where shopspList.Count(d => d.id.ToString().Trim() == body.id_shopsp.ToString().Trim() && (d.dw == null || d.dw == "")) > 0
                                      select body).ToList();
                if (noDwShopspList != null && noDwShopspList.Count > 0)
                {
                    result.Success = false;
                    result.Message.Add(string.Format("审核失败,商品编码为[{0}] 单位 为空!", shopspList.Where(d => d.id == noDwShopspList.FirstOrDefault().id_shopsp).FirstOrDefault().bm));
                    throw new CySoftException(result);
                }


                var noIdSpList = (from body in dbModel.body
                                  where shopspList.Count(d => d.id_sp.ToString().Trim() == body.id_sp.ToString().Trim()) == 0
                                  select body).ToList();
                if (noIdSpList != null && noIdSpList.Count > 0)
                {
                    result.Success = false;
                    result.Message.Add(string.Format("过账失败,门店[{0}]不存在商品[{1}]的id_sp", dbModel.head.shop_name, noIdSpList.FirstOrDefault().shopsp_name));
                    throw new CySoftException(result);
                }

                #endregion
                #region 执行存储过程并返回结果
                ht.Clear();
                ht.Add("proname", "p_xs_dd_sh");
                ht.Add("errorid", "-1");
                ht.Add("errormessage", "未知错误!");
                ht.Add("id_bill", dbModel.head.id);
                ht.Add("id_user", id_user);
                DAL.RunProcedure(ht);

                if (!ht.ContainsKey("errorid") || !ht.ContainsKey("errormessage"))
                {
                    result.Success = false;
                    result.Message.Add("审核失败,执行审核出现异常!");
                    throw new CySoftException(result);
                }

                if (!string.IsNullOrEmpty(ht["errorid"].ToString()) || !string.IsNullOrEmpty(ht["errormessage"].ToString()))
                {
                    result.Success = false;
                    result.Message.Add(ht["errormessage"].ToString());
                    throw new CySoftException(result);
                }

                result.Success = true;
                result.Message.Add("审核成功,审核成功!");
                return(result);

                #endregion
            }
            #endregion
        }
Example #25
0
        /// <summary>
        ///删除
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public override BaseResult Delete(Hashtable param)
        {
            #region 参数验证
            BaseResult result = new BaseResult()
            {
                Success = true
            };
            if (param == null || param.Count < 2)
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            var id            = param["id"].ToString();
            var id_masteruser = param["id_masteruser"].ToString();
            if (string.IsNullOrEmpty(id))
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            if (string.IsNullOrEmpty(id_masteruser))
            {
                result.Success = false;
                result.Message.Add("请登录!");
                return(result);
            }
            #endregion
            #region 更新数据
            Hashtable ht = new Hashtable();
            ht.Add("id", id);
            var brXs = this.Get(ht);
            if (!brXs.Success)
            {
                return(brXs);
            }
            else
            {
                Td_Xs_Dd_1_Query_DetailModel dbModel = (Td_Xs_Dd_1_Query_DetailModel)brXs.Data;
                if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id) || dbModel.body == null || dbModel.body.Count() <= 0)
                {
                    result.Success = false;
                    result.Message.Add("获取销售订单信息不符合要求!");
                    return(result);
                }

                if (dbModel.head.flag_sh == (byte)Enums.FlagSh.HadSh)
                {
                    result.Success = false;
                    result.Message.Add("该单据已经审核,不允许删除!");
                    return(result);
                }

                ht.Clear();
                ht.Add("id", id);
                ht.Add("id_masteruser", id_masteruser);
                ht.Add("flag_sh", (byte)Enums.FlagSh.UnSh);
                ht.Add("new_flag_delete", (int)Enums.FlagDelete.Deleted);

                try
                {
                    if (DAL.UpdatePart(typeof(Td_Xs_Dd_1), ht) <= 0)
                    {
                        result.Success = false;
                        result.Message.Add("删除操作失败!");
                        return(result);
                    }
                }
                catch (Exception ex)
                {
                    result.Success = false;
                    result.Message.Add("删除操作异常!");
                }
                #endregion
                return(result);
            }
        }
Example #26
0
        public async Task <ActionResult> GetMergeBarCode(List <ArList> arList)
        {
            BaseResult <MergeBarcodeOutput> result = await this.GetMergeBarCodeData(arList);

            return(this.Json(result));
        }
Example #27
0
        public override BaseResult Update(dynamic entity)
        {
            BaseResult res = new BaseResult()
            {
                Success = true
            };
            UpdateParmShop model = entity as UpdateParmShop;

            if (model == null ||
                string.IsNullOrEmpty(model.id_masteruser) ||
                string.IsNullOrEmpty(model.id))
            {
                res.Success = false;
                res.Message.Add("参数有误!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.parmvalue))
            {
                res.Success = false;
                res.Message.Add("参数值不能为空!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.id_shop) || string.IsNullOrEmpty(model.id_shop_master))
            {
                res.Success = false;
                res.Message.Add("操作失败!");
                return(res);
            }

            var id_shop       = model.id_shop;
            var parmvalue     = model.parmvalue;
            var id_masteruser = model.id_masteruser;
            var id            = model.id;

            Hashtable ht = new Hashtable();

            ht.Add("id_masteruser", id_masteruser);
            ht.Add("id", id);
            var oldModel = DAL.GetItem <Ts_Parm_Shop>(typeof(Ts_Parm_Shop), ht);

            if (oldModel == null)
            {
                res.Success = false;
                res.Message.Add("数据已不存在!");
                return(res);
            }
            if (!ParmValidation.Valid(oldModel.regex, parmvalue, res) && oldModel.flag_editstyle != 1)
            {
                return(res);
            }
            if (ParmValidation.NeedValidParmCode(oldModel.parmcode) && oldModel.flag_editstyle != 1)
            {
                if (!ParmValidation.ValidDigit(parmvalue, oldModel.parmvalue, res))
                {
                    return(res);
                }
            }
            Hashtable param = new Hashtable();

            if (model.id_shop == oldModel.id_shop && model.id_shop == model.id_shop_master)
            {
                param.Clear();
                param.Add("id_masteruser", model.id_masteruser);
                param.Add("id", model.id);
                param.Add("new_parmvalue", model.parmvalue);
                DAL.UpdatePart(typeof(Ts_Parm_Shop), param);
            }
            else
            {
                param.Clear();
                param.Add("id_masteruser", model.id_masteruser);
                param.Add("id_shop", id_shop);
                param.Add("parmcode", oldModel.parmcode);
                var count = DAL.GetCount(typeof(Ts_Parm_Shop), param);
                if (count == 1)
                {
                    param.Add("new_parmvalue", model.parmvalue);
                    DAL.UpdatePart(typeof(Ts_Parm_Shop), param);
                }
                else if (count == 0)
                {
                    Ts_Parm_Shop parmShop = new Ts_Parm_Shop()
                    {
                        id             = GetGuid,
                        flag_editstyle = oldModel.flag_editstyle,
                        id_masteruser  = id_masteruser,
                        id_shop        = id_shop,
                        parmcode       = oldModel.parmcode,
                        parmvalue      = model.parmvalue,
                        parmdescribe   = oldModel.parmdescribe,
                        regex          = oldModel.regex,
                        sort_id        = oldModel.sort_id,
                        version        = oldModel.version,
                        parmname       = oldModel.parmname
                    };
                    DAL.Add(parmShop);
                }
                else
                {
                    res.Success = false;
                    res.Message.Add("数据有误,请联系管理员!");
                    return(res);
                }
            }
            DataCache.Remove(id_masteruser + "_" + id_shop + "_GetShopParm");
            return(res);
        }
        public async Task <string> SignInAsync(LoginModel model)
        {
            BaseResult result = new BaseResult();

            #region 判断验证码
            if (!ValidateCaptchaCode(model.CaptchaCode))
            {
                result.ResultCode = ResultCodeAddMsgKeys.SignInCaptchaCodeErrorCode;
                result.ResultMsg  = ResultCodeAddMsgKeys.SignInCaptchaCodeErrorMsg;
                return(JsonHelper.ObjectToJSON(result));
            }
            #endregion

            #region 判断错误次数
            var ErrorTimes = HttpContext.Session.GetInt32(ManagerSignInErrorTimes);
            if (ErrorTimes == null)
            {
                HttpContext.Session.SetInt32(ManagerSignInErrorTimes, 1);
                ErrorTimes = 1;
            }
            else
            {
                HttpContext.Session.SetInt32(ManagerSignInErrorTimes, ErrorTimes.Value + 1);
            }
            if (ErrorTimes > MaxErrorTimes)
            {
                result.ResultCode = ResultCodeAddMsgKeys.SignInErrorTimesOverTimesCode;
                result.ResultMsg  = ResultCodeAddMsgKeys.SignInErrorTimesOverTimesMsg;
                return(JsonHelper.ObjectToJSON(result));
            }
            #endregion

            #region 再次属性判断
            LoginModelValidation validation = new LoginModelValidation();
            ValidationResult     results    = validation.Validate(model);
            if (!results.IsValid)
            {
                result.ResultCode = ResultCodeAddMsgKeys.CommonModelStateInvalidCode;
                result.ResultMsg  = results.ToString("||");
            }
            #endregion

            model.Ip = HttpContext.GetClientUserIp();
            var manager = await _service.SignInAsync(model);

            if (manager == null)
            {
                result.ResultCode = ResultCodeAddMsgKeys.SignInPasswordOrUserNameErrorCode;
                result.ResultMsg  = ResultCodeAddMsgKeys.SignInPasswordOrUserNameErrorMsg;
            }
            else if (manager.IsLock)
            {
                result.ResultCode = ResultCodeAddMsgKeys.SignInUserLockedCode;
                result.ResultMsg  = ResultCodeAddMsgKeys.SignInUserLockedMsg;
            }
            else
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, manager.UserName),
                    new Claim(ClaimTypes.Role, manager.RoleId.ToString()),
                    new Claim("Id", manager.Id.ToString()),
                    new Claim(ClaimTypes.Email, manager.Email ?? ""),
                    new Claim(ClaimTypes.MobilePhone, manager.Mobile ?? ""),
                    new Claim("LoginCount", manager.LoginCount.ToString()),
                    new Claim("LoginLastIp", manager.LoginLastIp),
                    new Claim("LoginLastTime", manager.LoginLastTime?.ToString("yyyy-MM-dd HH:mm:ss")),
                    new Claim("NickName", manager.NickName ?? "匿名"),
                    new Claim("Avatar", manager.Avatar ?? "/images/userface1.jpg"),
                };
                var claimsIdentity = new ClaimsIdentity(
                    claims, CookieAuthenticationDefaults.AuthenticationScheme);
                await HttpContext.SignInAsync(
                    CookieAuthenticationDefaults.AuthenticationScheme,
                    new ClaimsPrincipal(claimsIdentity));
            }
            return(JsonHelper.ObjectToJSON(result));
        }
Example #29
0
 public abstract bool HasData(BaseResult rs);
Example #30
0
        public string Ins()
        {
            var      result     = string.Empty;
            var      resultBase = new BaseResult();
            Currency model      = null;

            if (string.IsNullOrWhiteSpace(_json))
            {
                resultBase.status = "002"; resultBase.errmsg = "参数不能为空";
                result            = JsonConvert.SerializeObject(resultBase);
                LogHelper.WriteLog("WebApi", result);
                return(result);
            }
            try
            {
                model = JsonConvert.DeserializeObject <Currency>(_json);
            }
            catch (Exception)
            {
                resultBase.status = "002"; resultBase.errmsg = "Json字符串错误";
                result            = JsonConvert.SerializeObject(resultBase);
                LogHelper.WriteLog("WebApi", result);
                return(result);
            }


            if (string.IsNullOrWhiteSpace(model.OperationType))
            {
                resultBase.status = "002"; resultBase.errmsg = "操作类型不能为空";
                result            = JsonConvert.SerializeObject(resultBase);
                LogHelper.WriteLog("WebApi", result);
                return(result);
            }
            if (string.IsNullOrWhiteSpace(model.TableName))
            {
                resultBase.status = "002"; resultBase.errmsg = "表名不能为空";
                result            = JsonConvert.SerializeObject(resultBase);
                LogHelper.WriteLog("WebApi", result);
                return(result);
            }

            dal = new DAL.CurrencyDAL <object>(model.TableName);
            switch (model.OperationType)
            {
            case "001":      //查询
                List <object> list = dal.GetALL();
                resultBase.count  = list.Count;
                resultBase.data   = list;
                resultBase.status = "001";
                result            = JsonConvert.SerializeObject(resultBase);
                LogHelper.WriteLog("WebApi", result);
                break;

            case "002":      //添加数据
                if (dal.Add(model.Data))
                {
                    resultBase.status = "001";
                    resultBase.msg    = "添加成功";
                }
                else
                {
                    resultBase.status = "002";
                    resultBase.errmsg = "添加失败";
                }
                result = JsonConvert.SerializeObject(resultBase);
                LogHelper.WriteLog("WebApi", result);
                break;
            }
            return(result);
        }
Example #31
0
        public ActionResult Out(string obj)
        {
            BaseResult br = new BaseResult();

            try
            {
                Hashtable   param = JSON.Deserialize <Hashtable>(obj);
                ParamVessel p     = new ParamVessel();
                p.Add("head", null, HandleType.ReturnMsg);
                p.Add("body", null, HandleType.ReturnMsg);
                p.Add("ShoppingInfo", null, HandleType.Remove);
                param = param.Trim(p);
                Td_Sale_Out_Head head = JSON.ConvertToType <Td_Sale_Out_Head>(param["head"]);
                head.id_gys = GetLoginInfo <long>("id_supplier");
                List <Td_Sale_Out_Body> body         = JSON.ConvertToType <List <Td_Sale_Out_Body> >(param["body"]);
                ShoppingInfo            shoppinginfo = JSON.ConvertToType <ShoppingInfo>(param["ShoppingInfo"]);
                Ts_Sale_Order_Log       ts           = new Ts_Sale_Order_Log();//日志
                if (shoppinginfo != null)
                {
                    if (shoppinginfo.company_logistics == "")
                    {
                        shoppinginfo.company_logistics = "暂无";
                    }
                    if (shoppinginfo.no_logistics == "")
                    {
                        shoppinginfo.no_logistics = "暂无";
                    }
                    if (shoppinginfo.rq_fh == "")
                    {
                        shoppinginfo.rq_fh = DateTime.Now.ToString();
                    }
                }
                // 单号 赋值
                if (head.id_cgs <= 0)
                {
                    br.Success = false;
                    br.Message.Add("未知采购商,请刷新后再试!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (head.dh_order.IsEmpty())
                {
                    br.Success = false;
                    br.Message.Add("订单号丢失,请刷新后再试!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (head.id_gys <= 0)
                {
                    br.Success = false;
                    br.Message.Add("未知供应商,请刷新后再试!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (body.Count < 1)
                {
                    br.Success = false;
                    br.Message.Add("<h5>参数错误</h5>");
                    br.Message.Add("没有可保存的商品!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                int xh = 1;
                foreach (var item in body)
                {
                    if (item != null)
                    {
                        if (item.id_sku < 1)
                        {
                            br.Success = false;
                            br.Message.Add("<h5>参数错误</h5>");
                            br.Message.Add(String.Format("[代码:303],第{0}行数据中商品id有误!", xh));
                            br.Level = ErrorLevel.Warning;
                            return(Json(br));
                        }
                        if (item.sl <= 0m)
                        {
                            br.Success = false;
                            br.Message.Add("<h5>参数错误</h5>");
                            br.Message.Add(String.Format("[代码:303],第{0}行数据中商品数量有误!", xh));
                            br.Level = ErrorLevel.Warning;
                            return(Json(br));
                        }
                        //if (item.zhl <= 0m)
                        //{
                        //    br.Success = false;
                        //    br.Message.Add("<h5>参数错误</h5>");
                        //    br.Message.Add(String.Format("[代码:303],第{0}行数据中包装数有误!", xh));
                        //    br.Level = ErrorLevel.Warning;
                        //    return Json(br);
                        //}
                        xh++;
                    }
                }
                br = BusinessFactory.Utilety.GetNextDH(head, typeof(Td_Sale_Out_Head));

                if (!br.Success)
                {
                    return(Json(br));
                }
                ts.id             = BusinessFactory.Utilety.GetNextKey(typeof(Ts_Sale_Order_Log));
                ts.id_user        = GetLoginInfo <long>("id_user");
                ts.id_user_master = GetLoginInfo <long>("id_user_master");
                ts.flag_type      = 4;
                head.id_create    = GetLoginInfo <long>("id_user");
                head.id_edit      = GetLoginInfo <long>("id_user");

                param.Clear();
                param.Add("head", head);
                param.Add("body", body);
                param.Add("Ts", ts);
                param.Add("ShoppingInfo", shoppinginfo);
                param.Add("id_user_master", GetLoginInfo <long>("id_user_master"));

                br = BusinessFactory.ShippingRecord.Add(param);

                //#region 跳入分单批量插入出库单

                //var rs = BusinessFactory.GoodsSkuFd.Query_Sale_Order_Head(head.dh_order);
                //if (rs.flag_fd != 1)
                //{
                //    BusinessFactory.GoodsSkuFd.SaleOut_Out_Fd(head.dh_order, head.dh);
                //}

                //#endregion

                return(Json(br));
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #32
0
 public abstract void CloseResult(BaseResult rs);
Example #33
0
        /// <summary>
        /// 获取会员金额
        /// lz
        /// 2016-10-18
        /// </summary>
        public override BaseResult Get(Hashtable param)
        {
            BaseResult res = new BaseResult()
            {
                Success = true
            };

            #region 检查会员状态
            var br = base.CheckHY(param);
            if (!br.Success)
            {
                throw new CySoftException(br);
            }
            #endregion

            try
            {
                var brJe = this.GetOne(param);
                if (!brJe.Success)
                {
                    res.Success = false;
                    res.Message.Add("会员金额数据不存在!");
                }
                else
                {
                    var dbInfo = (Tz_Hy_Je)brJe.Data;
                    if (dbInfo == null || string.IsNullOrEmpty(dbInfo.id))
                    {
                        res.Success = true;
                        res.Data    = new Tz_Hy_Je()
                        {
                            je_qm = 0, je_qm_zs = 0
                        };
                        res.Message.Add("查询成功!");
                    }
                    else
                    {
                        if (RecordKeyError(dbInfo))
                        {
                            res.Success = false;
                            res.Message.Add("会员金额数据非法!");
                        }
                        else if (ZBError(dbInfo))
                        {
                            res.Success = false;
                            res.Message.Add("会员金额账本数据非法!");
                        }
                        else
                        {
                            res.Data = dbInfo;
                            res.Message.Add("查询成功!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                res.Success = false;
                res.Message.Add("系统异常!");
            }
            return(res);
        }
Example #34
0
        public ActionResult CZRuleSet(Model.Tb.Tb_Hy_Jfrule model)
        {
            BaseResult br       = new BaseResult();
            var        oldParam = new Hashtable();


            try
            {
                #region 获取参数
                Hashtable   param = base.GetParameters();
                ParamVessel p     = new ParamVessel();
                p.Add("table_info", string.Empty, HandleType.ReturnMsg); //table_info
                p.Add("type", string.Empty, HandleType.Remove);          //type
                param = param.Trim(p);
                param.Add("id_masteruser", id_user_master);
                param.Add("id_user", id_user);
                param.Add("id_shop", id_shop);
                oldParam = (Hashtable)param.Clone();
                #endregion
                #region 参数验证

                if (string.IsNullOrEmpty(param["table_info"].ToString()))
                {
                    br.Success = false;
                    br.Message.Add("参数不符合要求!");
                    WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);
                    return(base.JsonString(br, 1));
                }

                var list = JSON.Deserialize <List <Td_Hy_Czrule_1_ReqModel> >(param["table_info"].ToString()) ?? new List <Td_Hy_Czrule_1_ReqModel>();

                if (list == null || list.Count() <= 0)
                {
                    br.Success = false;
                    br.Message.Add("请先添加需要新增的充值规则!");
                    WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);
                    return(base.JsonString(br, 1));
                }

                foreach (var item in list)
                {
                    var tempList = JSON.Deserialize <List <Td_Hy_Czrule_2> >(item.sp_list) ?? new List <Td_Hy_Czrule_2>();
                    item.czrule_2_list = tempList;

                    if (item.je_cz <= 0)
                    {
                        br.Success = false;
                        br.Message.Add("充值金额必须大于0!");
                        WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);
                        return(base.JsonString(br, 1));
                    }

                    if (item.je_cz_zs < 0)
                    {
                        br.Success = false;
                        br.Message.Add("赠送金额不允许小于0!");
                        WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);
                        return(base.JsonString(br, 1));
                    }

                    if (item.je_cz_zs == 0 && item.czrule_2_list.Count() <= 0)
                    {
                        br.Success = false;
                        br.Message.Add("赠送金额为0时 必须选择赠送商品!");
                        WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);
                        return(base.JsonString(br, 1));
                    }
                }

                param.Add("list", list);

                #endregion


                if (param.ContainsKey("type") && param["type"].ToString() == "edit")
                {
                    #region 更新
                    br = BusinessFactory.Td_Hy_Czrule_1.Update(param);
                    #endregion
                }
                else
                {
                    #region 新增
                    br = BusinessFactory.Td_Hy_Czrule_1.Add(param);
                    #endregion
                }

                #region 返回
                WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);

                return(base.JsonString(br, 1));

                #endregion
            }
            catch (Exception ex)
            {
                #region 异常返回
                br.Success = false;
                br.Data    = "";
                br.Message.Add("数据不符合要求!");
                br.Level = ErrorLevel.Warning;
                WriteDBLog("会员充值规则-新增/编辑页面Post", oldParam, br);
                return(base.JsonString(br, 1));

                #endregion
            }
        }
Example #35
0
        private PageNavigate GetBuyerIndex()
        {
            PageNavigate pn        = new PageNavigate();
            string       checktype = "";
            DateTime     dt        = DateTime.Now;
            BaseResult   br        = new BaseResult();

            try
            {
                Hashtable   param           = base.GetParameters();
                ParamVessel p               = new ParamVessel();
                var         flag_state_List = new List <int>();
                p.Add("checktype", String.Empty, HandleType.Remove);
                param = param.Trim(p);
                if (param["checktype"] != null)
                {
                    checktype = param["checktype"].ToString();
                }
                else
                {
                    checktype = null;
                }
                //long id_cgs = GetLoginInfo<long>("id_buyer");
                string id_user_master = GetLoginInfo <string>("id_user_master");
                param.Add("id_user", GetLoginInfo <string>("id_user"));
                param.Add("sort", "rq");
                param.Add("dir", "desc");
                br = BusinessFactory.Log.Get(param);
                ViewData["buyer_Log"] = (Ts_Log)br.Data ?? new Ts_Log()
                {
                    rq = DateTime.Now
                };
                param.Clear();
                param["day"]   = dt.Day;
                param["month"] = dt.Month;
                param["year"]  = dt.Year;
                //param["id_cgs"] = id_cgs;
                param.Add("not_flag_state", 0);
                br = BusinessFactory.Report.GetAll(param);
                ViewData["buyer_day"] = br.Data;
                param.Clear();
                param["month"] = dt.Month;
                param["year"]  = dt.Year;
                //param["id_cgs"] = id_cgs;
                param.Add("not_flag_state", 0);
                br = BusinessFactory.Report.GetAll(param);
                ViewData["buyer_month"] = br.Data;
                param.Clear();
                param["year"] = dt.Year;
                //param["id_cgs"] = id_cgs;
                param.Add("not_flag_state", 0);
                br = BusinessFactory.Report.GetAll(param);
                ViewData["buyer_year"] = br.Data;
                param.Clear();
                param["flag_state"] = 10;
                flag_state_List.AddRange(new List <int> {
                    (int)OrderFlag.Submitted, (int)OrderFlag.OrderCheck, (int)OrderFlag.FinanceCheck, (int)OrderFlag.WaitOutputCheck, (int)OrderFlag.WaitDelivery
                });
                param.Add("flag_state_List", flag_state_List);
                //param["id_cgs"] = id_cgs;
                br = BusinessFactory.Report.GetAll(param);
                ViewData["buyer_Pending"] = br.Data;
                param.Clear();
                if (checktype == null)
                {
                    param["rq_create"]  = Convert.ToDateTime(dt.AddDays(1 - (dt.Day))).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    param["end_create"] = Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    param["checktype"]  = checktype;
                }
                if (checktype == "2")
                {
                    param["rq_create"]  = Convert.ToDateTime(dt.AddMonths(-6)).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    param["end_create"] = Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    param["checktype"]  = "2";
                }
                else if (checktype == "3")
                {
                    param["rq_create"]  = Convert.ToDateTime(dt.AddYears(-1)).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    param["end_create"] = Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    param["checktype"]  = "2";
                }
                //param["id_cgs"] = id_cgs;
                pn = BusinessFactory.Report.GetDataforImg(param);
                param.Clear();
                //我的通知信息(只获取最新的10条数据)
                PageList <Info_Query> lst = new PageList <Info_Query>(10);
                param.Add("limit", 10);
                param.Add("start", 0);
                param.Add("id_user", GetLoginInfo <string>("id_user"));
                string[] bm = new string[] { "update", "system", "business" };
                param.Add("bmList", bm);
                PageNavigate pn1 = BusinessFactory.InfoUser.GetPage(param);
                lst = new PageList <Info_Query>(pn1, 1, 10);
                ViewData["buyer_infoList"]    = lst;
                ViewData["buyer_id_cgs"]      = GetLoginInfo <string>("id_buyer");
                ViewData["buyer_report_data"] = pn.Data;
                return(pn);
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #36
0
        /// <summary>
        /// Returns information to identify the ME model. 
        /// </summary>  
        public BaseResult<GenericTypeResult<string>> GetModelInformation()
        {
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();

            s.Start(); 
            string response = Connector.Execute(Command.ToString(Commands.GMM));
            s.Stop();

            Match match = new Regex(@"\+GMM(\r|\r\r\n|r\n)(.*[A-Za-z0-9-_ #$%+=@!{},/|`~&*()'<>?.:;_].*)\r\rOK\r").Match(response);
            if (match.Success)
            { 
                response = match.Groups[2].Value;
                ret.Response.Result = response.Trim();
                this.Model = ret.Response.Result;
            } 
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #37
0
        /// <summary>
        /// Set whether error messages should be displayed in numeric format or verbose format.
        /// </summary>
        /// <param name="format">Value between 1 (Numeric) and 2 (Verbose)</param>
        public BaseResult<GenericTypeResult<bool>> SetErrorMessageFormat(int format)
        {
            BaseResult<GenericTypeResult<bool>> ret = new BaseResult<GenericTypeResult<bool>>();
            Stopwatch s = new Stopwatch();
            s.Start();
            string response = Connector.Execute(Command.Set(Commands.CMEE, format.ToString()));
            s.Stop();

            if (response.Contains("OK"))
            {
                ret.Response.Result = true;
            }

            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #38
0
 public object GetMetaList(BaseResult result)
 {
     return(CacheRouteMappingGenrator.AllMetaDataResult());
 }
Example #39
0
        /// <summary>
        /// Get the TA about the character set used by the TE.
        /// </summary>  
        public BaseResult<GenericTypeResult<string>> GetCharacterSet()
        {
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();

            s.Start(); 
            string response = Connector.Execute(Command.Get(Commands.CSCS));
            s.Stop();

            Match match = new Regex(@"\+CSCS: " + (char)34 + @"(.*[A-Za-z0-9].*)" + (char)34).Match(response);
            if (match.Success)
            {
                ret.Response.Result = match.Groups[1].Value; 
            }
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #40
0
        /// <summary>
        /// Get the reporting of ME errors.
        /// </summary>  
        public BaseResult<GenericTypeResult<int>> GetErrorMessageFormat()
        {
            BaseResult<GenericTypeResult<int>> ret = new BaseResult<GenericTypeResult<int>>();
            Stopwatch s = new Stopwatch();

            s.Start(); 
            string response = Connector.Execute(Command.Get(Commands.CMEE));
            s.Stop();

            Match match = new Regex(@"\+CMEE: (\d+)").Match(response);
            if (match.Success)
            {
                response = match.Groups[1].Value;
                ret.Response.Result = Convert.ToInt32(response);
            }
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #41
0
        public override BaseResult Update(dynamic entity)
        {
            #region 获取数据
            Hashtable  param           = (Hashtable)entity;
            BaseResult br              = new BaseResult();
            Hashtable  ht              = new Hashtable();
            var        td_Xs_Dd_2_List = (List <Td_Xs_Dd_2>)param["shopspList"];

            var digit = param["DigitHashtable"] as System.Collections.Hashtable;//小数点控制

            if (!param.ContainsKey("id") || string.IsNullOrEmpty(param["id"].ToString()))
            {
                br.Message.Add(String.Format("操作失败 缺少必要参数!"));
                br.Success = false;
                return(br);
            }

            #region 检测此单号是否已经存在

            ht.Clear();
            ht.Add("id", (param["id"].ToString()));
            var brXs = this.Get(ht);
            if (!brXs.Success)
            {
                return(brXs);
            }

            Td_Xs_Dd_1_Query_DetailModel dbModel = (Td_Xs_Dd_1_Query_DetailModel)brXs.Data;
            if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id))
            {
                br.Success = false;
                br.Message.Add("获取销售订单信息不符合要求!");
                return(br);
            }


            ht.Clear();
            ht.Add("id", param["id"].ToString());
            if (DAL.GetCount(typeof(Td_Xs_Dd_1), ht) <= 0)
            {
                br.Success = false;
                br.Message.Add("未查询到此id订单,请重试!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", param["id_masteruser"].ToString());
            ht.Add("dh", param["dh"].ToString());
            ht.Add("not_id", param["id"].ToString());
            if (DAL.GetCount(typeof(Td_Xs_Dd_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("新单号已经重复,请核实!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", param["id_masteruser"].ToString());
            ht.Add("dh", param["dh"].ToString());
            if (DAL.GetCount(typeof(Td_Xs_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在销售出库单中,请核实!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", param["id_masteruser"].ToString());
            ht.Add("dh", param["dh"].ToString());
            if (DAL.GetCount(typeof(Td_Sk_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在收款单中,请核实!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", param["id_masteruser"].ToString());
            ht.Add("dh", param["dh"].ToString());
            if (DAL.GetCount(typeof(Td_Xs_Th_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在销售退货单中,请核实!");
                return(br);
            }

            if (NeedCheckXY_XS(dbModel.head.id_masteruser))
            {
                var xyed = GetCanUseMoneyForKH(dbModel.head.id_masteruser, dbModel.head.id_shop, dbModel.head.id_kh, dbModel.head.id, Enums.Ps.XS010.ToString());
                if (td_Xs_Dd_2_List.Sum(d => d.je) > xyed)
                {
                    br.Success = false;
                    br.Message.Add(string.Format("此单总金额超过可用信用额度[{0:F}]!", xyed));
                    return(br);
                }
            }

            var shopModel = QueryShopById(dbModel.head.id_shop);
            if (shopModel == null || shopModel.id.IsEmpty())
            {
                br.Success = false;
                br.Message.Add("该门店已停用或删除 请选择其他门店!");
                return(br);
            }

            #endregion

            int xh = 1;

            foreach (var item in td_Xs_Dd_2_List)
            {
                item.id            = Guid.NewGuid().ToString();
                item.id_masteruser = param["id_masteruser"].ToString();
                item.id_bill       = param["id"].ToString();
                item.sort_id       = xh;
                item.rq_create     = DateTime.Parse(param["rq"].ToString());
                xh++;
            }


            #endregion
            #region 操作数据库
            ht.Clear();
            ht.Add("id", param["id"].ToString());
            ht.Add("new_dh", param["dh"].ToString());
            ht.Add("new_rq", DateTime.Parse(param["rq"].ToString()));
            ht.Add("new_rq_jh", DateTime.Now.AddYears(1));
            ht.Add("new_id_shop", param["id_shop"].ToString());
            ht.Add("new_flag_ddlx", param["flag_ddlx"].ToString());
            ht.Add("new_flag_dhtype", param["flag_dhtype"].ToString());
            ht.Add("new_id_kh", param["id_kh"].ToString());
            ht.Add("new_id_jbr", param["id_jbr"].ToString());
            ht.Add("new_bz", param["remark"].ToString());
            ht.Add("new_je_mxtotal", td_Xs_Dd_2_List.Sum(d => d.je));
            ht.Add("new_id_edit", param["id_user"].ToString());
            ht.Add("new_rq_edit", DateTime.Now);


            DAL.UpdatePart(typeof(Td_Xs_Dd_1), ht);

            ht.Clear();
            ht.Add("id_bill", param["id"].ToString());
            DAL.Delete(typeof(Td_Xs_Dd_2), ht);
            DAL.AddRange <Td_Xs_Dd_2>(td_Xs_Dd_2_List);
            #endregion
            br.Message.Add(String.Format("操作成功!"));
            br.Success = true;
            br.Data    = param["id"].ToString();
            return(br);
        }
Example #42
0
        public ActionResult SetJeMinMax()
        {
            BaseResult br = new BaseResult();

            var oldParam = new Hashtable();


            try
            {
                Hashtable   param = base.GetParameters();
                ParamVessel p     = new ParamVessel();
                p.Add("je_obj", string.Empty, HandleType.ReturnMsg);//je_obj
                param = param.Trim(p);
                param.Add("id_user", id_user);
                param.Add("id_masteruser", id_user_master);
                param.Add("id_shop", id_shop);
                oldParam = (Hashtable)param.Clone();
                var je_obj = JSON.Deserialize <Ts_HykDbjf>(param["je_obj"].ToString()) ?? new Ts_HykDbjf();
                je_obj.id_masteruser = id_user_master;
                param.Remove("je_obj");
                param.Add("je_obj", je_obj);

                #region 验证参数

                if (!string.IsNullOrEmpty(je_obj.hy_czje_min_onec) && !CyVerify.IsNumeric(je_obj.hy_czje_min_onec))
                {
                    return(base.JsonString(new { status = "error", message = string.Join(";", "每次最小金额格式错误") }));
                }

                if (!string.IsNullOrEmpty(je_obj.hy_czje_max_onec) && !CyVerify.IsNumeric(je_obj.hy_czje_max_onec))
                {
                    return(base.JsonString(new { status = "error", message = string.Join(";", "每次最大金额格式错误") }));
                }

                if (!string.IsNullOrEmpty(je_obj.hy_czje_max_month) && !CyVerify.IsNumeric(je_obj.hy_czje_max_month))
                {
                    return(base.JsonString(new { status = "error", message = string.Join(";", "每月最大金额格式错误") }));
                }


                if (!string.IsNullOrEmpty(je_obj.hy_czje_min_onec) && !string.IsNullOrEmpty(je_obj.hy_czje_max_onec))
                {
                    if (decimal.Parse(je_obj.hy_czje_min_onec) > decimal.Parse(je_obj.hy_czje_max_onec))
                    {
                        return(base.JsonString(new { status = "error", message = string.Join(";", "每次最小金额 不能大于 每次最大金额!") }));
                    }
                }

                if (!string.IsNullOrEmpty(je_obj.hy_czje_min_onec) && !string.IsNullOrEmpty(je_obj.hy_czje_max_month))
                {
                    if (decimal.Parse(je_obj.hy_czje_min_onec) > decimal.Parse(je_obj.hy_czje_max_month))
                    {
                        return(base.JsonString(new { status = "error", message = string.Join(";", "每次最小金额 不能大于 每月最大金额!") }));
                    }
                }

                if (!string.IsNullOrEmpty(je_obj.hy_czje_max_onec) && !string.IsNullOrEmpty(je_obj.hy_czje_max_month))
                {
                    if (decimal.Parse(je_obj.hy_czje_max_onec) > decimal.Parse(je_obj.hy_czje_max_month))
                    {
                        return(base.JsonString(new { status = "error", message = string.Join(";", "每次最大金额 不能大于 每月最大金额!") }));
                    }
                }


                #endregion

                br = BusinessFactory.Td_Hy_Czrule_1.Active(param);

                if (br.Success)
                {
                    WriteDBLog("会员充值-充值设置金额参数", oldParam, br);
                    base.ClearShopParm(je_obj.id_masteruser, je_obj.id_shop);
                    return(base.JsonString(new
                    {
                        status = "success",
                        message = "执行成功,正在载入页面..."
                    }));
                }
                else
                {
                    WriteDBLog("会员充值-充值设置金额参数", oldParam, br);
                    return(base.JsonString(new
                    {
                        status = "error",
                        message = string.Join(";", br.Message)
                    }));
                }
            }
            catch (CySoftException ex)
            {
                WriteDBLog("会员充值-充值设置金额参数", oldParam, br);
                throw ex;
            }
            catch (Exception ex)
            {
                WriteDBLog("会员充值-充值设置金额参数", oldParam, br);
                throw ex;
            }
        }
Example #43
0
        /// <summary>
        /// Selects the level of functionality in the ME.
        /// </summary>
        /// <param name="level">The level of modem functionality.</param> 
        public BaseResult<GenericTypeResult<bool>> SetFunctionality(FunctionalityLevel level)
        {
            string response = Commands.RESULT_OK;
            BaseResult<GenericTypeResult<bool>> ret = new BaseResult<GenericTypeResult<bool>>();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connector.Execute(Command.Set(Commands.CFUN, (int)level), delayWhenRead:2000);
            s.Stop();

            if (response.Contains(Commands.RESULT_OK))
            {
                ret.Response.Result = true;
            }
            else
            {
                ret.Response.Result = false;
            }
            ret.ExecutionTime = s.Elapsed; 
            return ret;
        }
Example #44
0
        /// <summary>
        ///作废
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public override BaseResult Stop(Hashtable param)
        {
            #region 参数验证
            BaseResult result = new BaseResult()
            {
                Success = true
            };
            if (param == null || param.Count < 3)
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            var id            = param["id"].ToString();
            var id_masteruser = param["id_masteruser"].ToString();
            var id_user       = param["id_user"].ToString();

            if (string.IsNullOrEmpty(id))
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            if (string.IsNullOrEmpty(id_masteruser) || string.IsNullOrEmpty(id_user))
            {
                result.Success = false;
                result.Message.Add("请登录!");
                return(result);
            }
            #endregion
            #region 更新数据

            Hashtable ht = new Hashtable();
            ht.Add("id", id);
            var brXs = this.Get(ht);
            if (!brXs.Success)
            {
                return(brXs);
            }
            else
            {
                #region 校验商品合法性
                Td_Xs_Dd_1_Query_DetailModel dbModel = (Td_Xs_Dd_1_Query_DetailModel)brXs.Data;
                if (dbModel == null || dbModel.head == null || string.IsNullOrEmpty(dbModel.head.id))
                {
                    result.Success = false;
                    result.Message.Add("获取销售订单信息不符合要求!");
                    return(result);
                }
                #endregion
                #region 执行存储过程并返回结果
                ht.Clear();
                ht.Add("proname", "p_xs_dd_zf");
                ht.Add("errorid", "-1");
                ht.Add("errormessage", "未知错误!");
                ht.Add("id_bill", dbModel.head.id);
                ht.Add("id_user", id_user);
                DAL.RunProcedure(ht);

                if (!ht.ContainsKey("errorid") || !ht.ContainsKey("errormessage"))
                {
                    result.Success = false;
                    result.Message.Add("作废失败,返回参数出现异常!");
                    throw new CySoftException(result);
                }

                if (!string.IsNullOrEmpty(ht["errorid"].ToString()) || !string.IsNullOrEmpty(ht["errormessage"].ToString()))
                {
                    result.Success = false;
                    result.Message.Add(ht["errormessage"].ToString());
                    throw new CySoftException(result);
                }

                result.Success = true;
                result.Message.Add("作废操作成功!");
                return(result);

                #endregion
            }
            #endregion
        }
Example #45
0
        /// <summary>
        /// Get signal quality, approximate dBm.
        /// </summary>
        /// <returns>in percent</returns> 
        public BaseResult<GenericTypeResult<int>> GetSignalQuality()
        {
            Stopwatch s = new Stopwatch();
            BaseResult<GenericTypeResult<int>> ret = new BaseResult<GenericTypeResult<int>>();

            s.Start();
            string response = Connector.Execute(Command.ToString(Commands.CSQ));
            s.Stop();

            Match match = new Regex(@"\+CSQ: (\d+),(\d+)").Match(response);
            if (match.Success)
                response = match.Groups[1].Value;
            else
                response = "";

            int signal = 0;
            if (response != "")
            {
                signal = (-113) + (2 * Convert.ToInt32(response));
                this.SignalQuality = signal;
            }

            ret.Response.Result = signal;
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #46
0
        /// <summary>
        ///是否允许出库
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public override BaseResult Export(Hashtable param)
        {
            #region 参数验证
            BaseResult result = new BaseResult()
            {
                Success = false
            };
            if (param == null || param.Count < 3)
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            var id            = param["id"].ToString();
            var id_masteruser = param["id_masteruser"].ToString();
            var id_user       = param["id_user"].ToString();

            if (string.IsNullOrEmpty(id))
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            if (string.IsNullOrEmpty(id_masteruser) || string.IsNullOrEmpty(id_user))
            {
                result.Success = false;
                result.Message.Add("请登录!");
                return(result);
            }
            #endregion
            #region 更新数据
            Hashtable ht = new Hashtable();
            ht.Add("id", id);
            ht.Add("id_masteruser", id_masteruser);
            ht.Add("start", 0);
            ht.Add("limit", 10);
            var data = DAL.QueryPage <Td_Xs_Dd_1_QueryModel>(typeof(Td_Xs_Dd_1), ht).FirstOrDefault();
            if (data == null || string.IsNullOrEmpty(data.id))
            {
                result.Success = false;
                result.Message.Add("未查询到符合的数据!");
                return(result);
            }

            var shopModel = QueryShopById(data.id_shop);
            if (shopModel == null || shopModel.id.IsEmpty())
            {
                result.Success = false;
                result.Message.Add("该门店已停用或删除 不允许操作!");
                return(result);
            }

            ht.Clear();
            ht.Add("id_bill_origin", id);
            ht.Add("flag_sh", (byte)Enums.FlagSh.UnSh);
            ht.Add("flag_delete", (byte)Enums.FlagDelete.NoDelete);
            if (DAL.GetCount(typeof(Td_Xs_1), ht) > 0)
            {
                result.Success = false;
                result.Message.Add("该订单存在引单未审核出库订单 不允许操作!");
                return(result);
            }

            if (data.finish_ck == 0 && data.flag_sh == 1 && data.flag_cancel == 0)
            {
                result.Success = true;
                result.Message.Add("允许出库操作!");
                return(result);
            }
            else
            {
                if (data.finish_ck == 1)
                {
                    result.Success = false;
                    result.Message.Add("本单据已完成出库 请刷新数据后重试!");
                    return(result);
                }
                if (data.flag_sh != 1)
                {
                    result.Success = false;
                    result.Message.Add("本单据还未审核 不允许出库!");
                    return(result);
                }
                if (data.flag_cancel != 0)
                {
                    result.Success = false;
                    result.Message.Add("本单据已作废 不允许出库!");
                    return(result);
                }
            }

            #endregion
            result.Success = false;
            result.Message.Add("本单据不允许出库!");
            return(result);
        }
Example #47
0
        /// <summary>
        /// Get the TA about the possible character set used by the TE.
        /// </summary>  
        public BaseResult<GenericTypeResult<List<string>>> GetPossibleCharacterSet()
        { 
            List<string> list = null;
            BaseResult<GenericTypeResult<List<string>>> ret = new BaseResult<GenericTypeResult<List<string>>>(); 
            Stopwatch s = new Stopwatch();

            s.Start(); 
            string response = Connector.Execute(Command.Check(Commands.CSCS));
            s.Stop(); 

            Match match = new Regex(@"\+CSCS: \(" + (char)34 + @"(.*[A-Za-z0-9].*)" + (char)34 + "," + (char)34 + @"(.*[A-Za-z0-9].*)" + (char)34 + "," + (char)34 + @"(.*[A-Za-z0-9].*)" + (char)34 + "," + (char)34 + @"(.*[A-Za-z0-9])" + (char)34 + @"\)").Match(response);
            list = new List<string>();
            if (match.Success)
            {
                for (int i = 1; i < match.Groups.Count; i++)
                { 
                    list.Add(match.Groups[i].Value); 
                }
            }
            ret.Response.Result = list;
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #48
0
        public override BaseResult Add(dynamic entity)
        {
            #region 获取数据
            Hashtable  param           = (Hashtable)entity;
            BaseResult br              = new BaseResult();
            Hashtable  ht              = new Hashtable();
            var        td_Xs_Dd_2_List = (List <Td_Xs_Dd_2>)param["shopspList"];

            var digit            = param["DigitHashtable"] as System.Collections.Hashtable;//小数点控制
            var td_Xs_Dd_1_Model = this.TurnTd_Xs_Dd_1Model(param);

            #region 检测此单号是否已经存在
            ht.Clear();
            ht.Add("id_masteruser", td_Xs_Dd_1_Model.id_masteruser);
            ht.Add("dh", td_Xs_Dd_1_Model.dh);
            if (DAL.GetCount(typeof(Td_Xs_Dd_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在销售订单中,请核实!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", td_Xs_Dd_1_Model.id_masteruser);
            ht.Add("dh", td_Xs_Dd_1_Model.dh);
            if (DAL.GetCount(typeof(Td_Xs_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在销售出库单中,请核实!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", td_Xs_Dd_1_Model.id_masteruser);
            ht.Add("dh", td_Xs_Dd_1_Model.dh);
            if (DAL.GetCount(typeof(Td_Sk_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在收款单中,请核实!");
                return(br);
            }

            ht.Clear();
            ht.Add("id_masteruser", td_Xs_Dd_1_Model.id_masteruser);
            ht.Add("dh", td_Xs_Dd_1_Model.dh);
            if (DAL.GetCount(typeof(Td_Xs_Th_1), ht) > 0)
            {
                br.Success = false;
                br.Message.Add("此单号已经存在销售退货单中,请核实!");
                return(br);
            }

            int xh = 1;

            foreach (var item in td_Xs_Dd_2_List)
            {
                item.id            = Guid.NewGuid().ToString();
                item.id_masteruser = td_Xs_Dd_1_Model.id_masteruser;
                item.id_bill       = td_Xs_Dd_1_Model.id;
                item.sort_id       = xh;
                item.rq_create     = td_Xs_Dd_1_Model.rq_create;
                xh++;
            }

            td_Xs_Dd_1_Model.je_mxtotal = td_Xs_Dd_2_List.Sum(d => d.je);



            if (NeedCheckXY_XS(td_Xs_Dd_1_Model.id_masteruser))
            {
                var xyed = GetCanUseMoneyForKH(td_Xs_Dd_1_Model.id_masteruser, td_Xs_Dd_1_Model.id_shop, td_Xs_Dd_1_Model.id_kh);
                if (td_Xs_Dd_1_Model.je_mxtotal > xyed)
                {
                    br.Success = false;
                    br.Message.Add(string.Format("此单总金额超过可用信用额度[{0:F}]!", xyed));
                    return(br);
                }
            }


            var shopModel = QueryShopById(td_Xs_Dd_1_Model.id_shop);
            if (shopModel == null || shopModel.id.IsEmpty())
            {
                br.Success = false;
                br.Message.Add("该门店已停用或删除 请选择其他门店!");
                return(br);
            }

            #endregion



            #endregion

            #region 插入数据库
            DAL.Add(td_Xs_Dd_1_Model);
            DAL.AddRange <Td_Xs_Dd_2>(td_Xs_Dd_2_List);
            #endregion

            #region 审核
            //审核
            if (param["autoAudit"].ToString().ToLower() == "true")
            {
                ht.Clear();
                ht.Add("id", td_Xs_Dd_1_Model.id);
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("id_user", param["id_user"].ToString());
                var brSh = this.ActiveWork(ht);
                if (!brSh.Success)
                {
                    br.Message.Clear();
                    br.Message.Add("审核操作失败,请重试!");
                    br.Success = false;
                    throw new CySoftException(br);
                }
            }

            #endregion

            br.Message.Add(String.Format("操作成功!"));
            br.Success = true;
            br.Data    = td_Xs_Dd_1_Model.id;
            return(br);
        }
Example #49
0
        /// <summary>
        /// Informs the TA about the character set used by the TE.
        /// </summary>
        /// <param name="characterSet">string ("IRA","GSM","PCCP437","8859-1") </param> 
        /// <returns>return true if OK, otherwise false.</returns> 
        public BaseResult<GenericTypeResult<bool>> SetCharacterSet(string characterSet)
        {
            BaseResult<GenericTypeResult<bool>> ret = new BaseResult<GenericTypeResult<bool>>();
            Stopwatch s = new Stopwatch();

            s.Start(); 
            string response = Connector.Execute(Command.Set(Commands.CSCS, (char)34 + characterSet + (char)34));
            s.Stop();

            if (response.Contains("OK"))
            {
                ret.Response.Result = true;
            }
            else
            {
                ret.Response.Result = false;
            }
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #50
0
File: InfoBLL.cs Project: 17/YunPos
        public override BaseResult Add(dynamic entity)
        {
            BaseResult br    = new BaseResult();
            Hashtable  param = (Hashtable)entity;
            Info       info  = new Info();

            info.id = long.Parse(param["id"].ToString());

            if (info.id == 0)
            {
                br.Data    = "id";
                br.Success = false;
                br.Level   = ErrorLevel.Error;
                br.Message.Add(string.Format("添加失败!标识列Id不能为空"));
                return(br);
            }
            if (param.ContainsKey("cgs_send"))
            {
                Hashtable param1 = new Hashtable();
                param1.Add("id_cgs", param["cgs_send"]);
                param1.Add("id_user_master_gys", param["id_master"]);
                Tb_Gys_Cgs gys_cgs = DAL.GetItem <Tb_Gys_Cgs>(typeof(Tb_Gys_Cgs), param1);
                param["id_user_master"] = gys_cgs.id_user_cgs;
            }
            if (param.ContainsKey("gys_send"))
            {
                Hashtable param2 = new Hashtable();
                param2.Add("id_gys", param["gys_send"]);
                param2.Add("id_user_master_cgs", param["id_master"]);
                Tb_Gys_Cgs gys_cgs = DAL.GetItem <Tb_Gys_Cgs>(typeof(Tb_Gys_Cgs), param2);
                param["id_user_master"] = gys_cgs.id_user_gys;
            }
            info.Title   = param["Title"].ToString();
            info.content = param["content"].ToString();
            if (param.ContainsKey("bm"))
            {
                Hashtable param3 = new Hashtable();
                param3.Add("bm", param["bm"]);
                Info_Type type = DAL.GetItem <Info_Type>(typeof(Info_Type), param3);
                param["id_info_type"] = type.id;
            }
            info.id_info_type = int.Parse(param["id_info_type"].ToString());
            info.id_create    = long.Parse(param["id_create"].ToString());
            info.id_master    = long.Parse(param["id_master"].ToString());
            info.flag_from    = param["flag_from"].ToString();
            //上传内容处理
            if (!String.IsNullOrEmpty(param["filename"].ToString()))
            {
                info.filename = param["filename"].ToString();
                info.filename = info.filename.Replace("Temp", "Info");
                info.fileSize = param["fileSize"].ToString();
                // 复制 原图 到 Info 文件夹下
                FileExtension.Copy(System.Web.HttpContext.Current.Server.MapPath(param["filename"].ToString()), System.Web.HttpContext.Current.Server.MapPath(info.filename));
            }
            info.sl_read = 0;

            DAL.Add(info);

            param.Remove("id");
            param.Remove("Title");
            param.Remove("content");
            param.Remove("id_info_type");
            param.Remove("flag_from");
            param.Remove("filename");
            //记录发送对象(数据插入info_user)
            param["rq_new"] = DateTime.Now;
            param.Add("flag_stop", 0);
            param.Add("_from", info.flag_from);
            param.Add("infoId", info.id);
            Info_UserDAL.BatchInsert_User(typeof(Info_User), param);

            //获取发送数量
            //long infoId = long.Parse(param["infoId"].ToString());
            //param.Clear();
            //param.Add("id_info", infoId);
            //info.sl_send = DAL.GetCount(typeof(Info_User), param);


            br.Success = true;
            return(br);
        }
Example #51
0
        /// <summary>
        /// Get SMSC address, through which mobile originated SMs are transmitted.
        /// </summary>  
        public BaseResult<GenericTypeResult<string>> GetServiceCenter()
        {
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();

            s.Start(); 
            string response = Connector.Execute(Command.Get(Commands.CSCA));
            s.Stop();

            Match match = new Regex(@"\+CSCA: " + (char)34 + @"(.*[0-9-_+].*)" + (char)34 + @",(\d+)").Match(response);
            if (match.Success)
            {
                response = match.Groups[1].Value;
                this.ServiceCenter = response;
            }
            else
            {
                response = ""; 
            }
            ret.Response.Result = response;
            ret.ExecutionTime = s.Elapsed;
            return ret;
        }
Example #52
0
        public override BaseResult Update(dynamic entity)
        {
            BaseResult res = new BaseResult()
            {
                Success = true
            };
            var model = entity as PssqModel;

            #region 参数验证
            if (model == null ||
                string.IsNullOrEmpty(model.id_masteruser) ||
                string.IsNullOrEmpty(model.id_shop) ||
                string.IsNullOrEmpty(model.id))
            {
                res.Success = false;
                res.Message.Add("参数有误!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.dh))
            {
                res.Success = false;
                res.Message.Add("请填写单号!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.id_shop))
            {
                res.Success = false;
                res.Message.Add("请选择申请门店!");
                return(res);
            }
            //if (string.IsNullOrEmpty(model.id_shop_sq))
            //{
            //    res.Success = false;
            //    res.Message.Add("请选择申请门店!");
            //    return res;
            //}
            //if (string.IsNullOrEmpty(model.id_shop_ck))
            //{
            //    res.Success = false;
            //    res.Message.Add("请选择配送门店!");
            //    return res;
            //}
            //if (model.id_shop_ck == model.id_shop_sq)
            //{
            //    res.Success = false;
            //    res.Message.Add("申请门店、配送门店不能相同!");
            //    return res;
            //}
            if (string.IsNullOrEmpty(model.id_jbr))
            {
                res.Success = false;
                res.Message.Add("请选择经办人!");
                return(res);
            }
            if (model.rq < new DateTime(2000, 01, 01))
            {
                res.Success = false;
                res.Message.Add("请输入开单日期!");
                return(res);
            }
            if (GetPsSktype(model.id_masteruser) != "0")
            {
                var xyed = GetCanUseMoney(model.id_masteruser, model.id_shop, model.id, Enums.Ps.PS010.ToString());
                if (model.je_mxtotal > xyed)
                {
                    res.Success = false;
                    res.Message.Add(string.Format("此单总金额超过可用信用额度[{0:F}]!", xyed));
                    return(res);
                }
            }
            #endregion
            Hashtable param = new Hashtable();
            #region 赋值
            param.Add("new_bm_djlx_origin", model.bm_djlx_origin ?? "");
            param.Add("new_id_bill_origin", model.id_bill_origin ?? "");
            param.Add("new_dh_origin", model.dh_origin ?? "");
            param.Add("new_id_shop", model.id_shop);
            param.Add("new_id_jbr", model.id_jbr);
            param.Add("new_je_mxtotal", model.je_mxtotal);
            param.Add("new_remark", string.Format("{0}", model.remark).Trim());

            param.Add("new_rq", model.rq);
            param.Add("id", model.id);
            param.Add("id_masteruser", model.id_masteruser);

            #endregion
            List <Td_Ps_Sq_2> pssq2S = new List <Td_Ps_Sq_2>();
            if (!string.IsNullOrEmpty(model.json_data))
            {
                pssq2S = JSON.Deserialize <List <Td_Ps_Sq_2> >(model.json_data);
                if (pssq2S.Any())
                {
                    int sort = 1;
                    pssq2S.ForEach(a =>
                    {
                        a.id            = GetGuid;
                        a.id_masteruser = model.id_masteruser;
                        a.id_bill       = model.id;
                        a.rq_create     = DateTime.Now;
                        a.sort_id       = sort++;
                        CheckModel2(res, a);
                    });
                }
            }
            if (!pssq2S.Any())
            {
                res.Success = false;
                res.Message.Add("请选择商品!");
                return(res);
            }
            if (res.Success == false)
            {
                var first = res.Message.First();
                res.Message.Clear();
                res.Message.Add(first);
                return(res);
            }
            Hashtable ht        = new Hashtable();
            var       shopModel = QueryShopById(model.id_shop);
            if (shopModel == null || shopModel.id_shop_ps.IsEmpty())
            {
                res.Success = false;
                res.Message.Add("申请门店已停用或删除!");
                return(res);
            }
            var id_sps   = (from p in pssq2S select p.id_sp).ToArray();
            var id_shops = new string[] { model.id_shop, shopModel.id_shop_ps };
            ht.Add("id_shop_array", id_shops);
            ht.Add("id_sp_array", id_sps);
            ht.Add("id_masteruser", model.id_masteruser);
            var splist = DAL.QueryList <Tb_Shopsp>(typeof(Tb_Shopsp), ht).ToList();
            pssq2S.ForEach(p =>
            {
                var sps = splist.Where(s => s.id_sp == p.id_sp);
                if (sps.Any() && sps.Count() >= 2)
                {
                    if (sps.Any(a => a.flag_delete != (byte)Enums.FlagDelete.NoDelete || a.flag_state != 1))
                    {
                        res.Success = false;
                        res.Message.Add(string.Format("第{0}行商品状态有变更,不能配货!", p.sort_id));
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message.Add(string.Format("第{0}行商品状态有变更,不能配货!", p.sort_id));
                }
            });
            if (res.Success == false)
            {
                var first = res.Message.First();
                res.Message.Clear();
                res.Message.Add(first);
                return(res);
            }
            DAL.UpdatePart(typeof(Td_Ps_Sq_1), param);
            param.Clear();
            param.Add("id_bill", model.id);
            param.Add("id_masteruser", model.id_masteruser);
            DAL.Delete(typeof(Td_Ps_Sq_2), param);
            DAL.AddRange(pssq2S);
            return(res);
        }
Example #53
0
        /// <summary>
        /// Return IMSI to identify the individual SIM card.
        /// </summary>  
        public BaseResult<GenericTypeResult<string>> GetIMSI()
        { 
            string response = "";
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();
             
            s.Start(); 
            response = Connector.Execute(Command.ToString(Commands.CIMI));
            s.Stop();

            Match match = new Regex(@"\+CIMI\r\r(\d+)").Match(response);
            if (match.Success)
            {
                response = match.Groups[1].Value;
            }
            else
            {
                response = "";
            }
            ret.Response.Result = response;
            ret.ExecutionTime = s.Elapsed;
            this.IntlMobileSubcriberID = response; 
            return ret;
        }
Example #54
0
        public override BaseResult Add(dynamic entity)
        {
            BaseResult res = new BaseResult()
            {
                Success = true
            };
            var model = entity as PssqModel;

            #region 参数验证
            if (model == null || string.IsNullOrEmpty(model.id_masteruser) || string.IsNullOrEmpty(model.id_shop))
            {
                res.Success = false;
                res.Message.Add("参数有误!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.dh))
            {
                res.Success = false;
                res.Message.Add("请填写单号!");
                return(res);
            }
            model.dh = model.dh.Trim();
            Hashtable _ck_parm = new Hashtable();
            _ck_parm.Add("dh", model.dh);
            _ck_parm.Add("id_masteruser", model.id_masteruser);
            if (DAL.GetCount(typeof(Td_Ps_Sq_1), _ck_parm) > 0)
            {
                res.Success = false;
                res.Message.Add("单号已存在!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.id_shop))
            {
                res.Success = false;
                res.Message.Add("请选择申请门店!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.id_jbr))
            {
                res.Success = false;
                res.Message.Add("请选择经办人!");
                return(res);
            }
            if (model.rq < new DateTime(2000, 01, 01))
            {
                res.Success = false;
                res.Message.Add("请输入开单日期!");
                return(res);
            }
            #endregion
            Td_Ps_Sq_1 pssq1 = new Td_Ps_Sq_1()
            {
                #region 赋值
                id_masteruser  = model.id_masteruser,
                id             = GetGuid,
                dh             = model.dh.Trim(),
                rq             = model.rq,
                id_shop        = model.id_shop,
                bm_djlx        = Enums.Ps.PS010.ToString(),
                bm_djlx_origin = model.bm_djlx_origin ?? "",
                id_bill_origin = model.id_bill_origin ?? "",
                dh_origin      = model.dh_origin ?? "",
                id_jbr         = model.id_jbr,
                je_mxtotal     = model.je_mxtotal,
                flag_sh        = (byte)Enums.FlagSh.UnSh,
                flag_cancel    = (byte)Enums.FlagCancel.NoCancel,
                bz             = string.Format("{0}", model.remark).Trim(),
                id_create      = model.id_create,
                rq_create      = DateTime.Now
                                 #endregion
            };
            model.id = pssq1.id;
            List <Td_Ps_Sq_2> pssq2S = new List <Td_Ps_Sq_2>();
            if (!string.IsNullOrEmpty(model.json_data))
            {
                pssq2S = JSON.Deserialize <List <Td_Ps_Sq_2> >(model.json_data);
                if (pssq2S.Any())
                {
                    int sort = 1;
                    pssq2S.ForEach(a =>
                    {
                        a.id            = GetGuid;
                        a.id_masteruser = pssq1.id_masteruser;
                        a.id_bill       = pssq1.id;
                        a.rq_create     = DateTime.Now;
                        a.sort_id       = sort++;
                        CheckModel2(res, a);
                    });
                }
            }
            if (!pssq2S.Any())
            {
                res.Success = false;
                res.Message.Add("请选择商品!");
                return(res);
            }
            if (res.Success == false)
            {
                var first = res.Message.First();
                res.Message.Clear();
                res.Message.Add(first);
                return(res);
            }
            var shopModel = QueryShopById(pssq1.id_shop);
            if (shopModel == null || shopModel.id_shop_ps.IsEmpty())
            {
                res.Success = false;
                res.Message.Add("申请门店已停用或删除!");
                return(res);
            }
            Hashtable param    = new Hashtable();
            var       id_sps   = (from p in pssq2S select p.id_sp).ToArray();
            var       id_shops = new string[] { pssq1.id_shop, shopModel.id_shop_ps };
            param.Add("id_shop_array", id_shops);
            param.Add("id_sp_array", id_sps);
            param.Add("id_masteruser", pssq1.id_masteruser);
            var splist = DAL.QueryList <Tb_Shopsp>(typeof(Tb_Shopsp), param).ToList();
            pssq2S.ForEach(p =>
            {
                var sps = splist.Where(s => s.id_sp == p.id_sp);
                if (sps.Any() && sps.Count() >= 2)
                {
                    if (sps.Any(a => a.flag_delete != (byte)Enums.FlagDelete.NoDelete || a.flag_state != 1))
                    {
                        res.Success = false;
                        res.Message.Add(string.Format("第{0}行商品状态有变更,不能配货!", p.sort_id));
                    }
                }
                else
                {
                    res.Success = false;
                    res.Message.Add(string.Format("第{0}行商品状态有变更,不能配货!", p.sort_id));
                }
            });
            if (res.Success == false)
            {
                var first = res.Message.First();
                res.Message.Clear();
                res.Message.Add(first);
                return(res);
            }
            if (GetPsSktype(model.id_masteruser) != "0")
            {
                var xyed = GetCanUseMoney(model.id_masteruser, model.id_shop);
                if (pssq1.je_mxtotal > xyed)
                {
                    res.Success = false;
                    res.Message.Add(string.Format("此单总金额超过可用信用额度[{0:F}]!", xyed));
                    return(res);
                }
            }
            DAL.Add(pssq1);
            DAL.AddRange(pssq2S);
            if (model.AutoAudit)
            {
                param.Clear();
                param.Add("id_masteruser", model.id_masteruser);
                param.Add("id_user", model.id_create);
                param.Add("id", model.id);
                Sh <Td_Ps_Sq_1>(res, param, "p_ps_sq_sh");
            }
            return(res);
        }
Example #55
0
        /// <summary>
        /// Returns the activity status of the mobile equipment
        /// </summary>
        /// <returns></returns>
        public BaseResult<GenericTypeResult<PhoneActivityStatus>> GetActivityStatus()
        {
            string response;
            BaseResult<GenericTypeResult<PhoneActivityStatus>> ret = new BaseResult<GenericTypeResult<PhoneActivityStatus>>();
            Stopwatch s = new Stopwatch();
            PhoneActivityStatus status = PhoneActivityStatus.Unavailable;

            s.Start();
            response = Connector.Execute(Command.ToString(Commands.CPAS));
            s.Stop();

            Match match = new Regex(@"\+CPAS: (\d+)").Match(response);
            if (match.Success)
            {
                switch (match.Groups[1].Value)
                {
                    case "0":
                        status = PhoneActivityStatus.Ready;
                        break;
                    case "1":
                        status = PhoneActivityStatus.Unavailable;
                        break;
                    case "2":
                        status = PhoneActivityStatus.Unknown;
                        break;
                    case "3":
                        status = PhoneActivityStatus.Ringing;
                        break;
                    case "4":
                        status = PhoneActivityStatus.CallInProgress;
                        break;
                    case "5":
                        status = PhoneActivityStatus.Sleep;
                        break; 
                }
            }
            ret.ExecutionTime = s.Elapsed;
            ret.Response.Result = status;
            return ret;
        }
Example #56
0
        public override BaseResult Export(Hashtable param)
        {
            BaseResult br = new BaseResult()
            {
                Success = true
            };
            Hashtable ht                        = new Hashtable();
            string    FilePath                  = string.Format("{0}", param["filePath"]);
            string    id_masteruser             = string.Format("{0}", param["id_masteruser"]);
            string    id_user                   = string.Format("{0}", param["id_user"]);
            string    id_shop                   = string.Format("{0}", param["id_shop"]);
            string    id_shop_ck                = string.Format("{0}", param["id_shop_ck"]);
            List <Ps_Shopsp_Import> list        = (List <Ps_Shopsp_Import>)param["list"];
            List <Ps_Shopsp_Import> successList = new List <Ps_Shopsp_Import>();
            List <Ps_Shopsp_Import> failList    = new List <Ps_Shopsp_Import>();

            #region 验证导入数据是否空
            if (list == null || list.Count() <= 0)
            {
                br.Message.Add(String.Format("操作失败,没有数据!"));
                br.Success = false;
                br.Data    = new PsShopsp_Import_All()
                {
                    SuccessList = successList, FailList = list, AllList = list
                };
                return(br);
            }
            #endregion

            #region 获取属于主用户所有门店商品
            ht.Clear();
            ht.Add("id_masteruser", id_masteruser);
            ht.Add("id_shop", id_shop);
            ht.Add("id_shop_ck", string.Format("'{0}'", id_shop_ck));
            var shopspList = Tb_ShopspDAL.GetPageListForPs(typeof(Tb_Shopsp), ht);
            if (shopspList == null || !shopspList.Any())
            {
                br.Message.Add(String.Format("操作失败,未查询到用户的商品数据!"));
                br.Success = false;
                br.Data    = new PsShopsp_Import_All()
                {
                    SuccessList = successList, FailList = list, AllList = list
                };
                return(br);
            }
            #endregion
            #region 验证导入的数据是否符合要求并相应简单处理赋值

            foreach (var item in list)
            {
                #region 验证必要参数是否符合
                int error = 0;
                if (string.IsNullOrEmpty(item.barcode))
                {
                    item.sysbz += "   条形码不能为空  ";
                    error++;
                }

                if (!CyVerify.IsNumeric(item.sl) || item.sl == 0)
                {
                    item.sysbz += "   数量不符合要求  ";
                    error++;
                }

                if (item.dj != null && !CyVerify.IsNumeric(item.dj))
                {
                    item.sysbz += "   单价不符合要求  ";
                    error++;
                }

                if (error > 0)
                {
                    continue;
                }
                #endregion

                #region 验证数据库是否存在数据并简单赋值
                var dbInfo = shopspList.Where(d => d.barcode == item.barcode.Trim() && d.flag_delete == (byte)Enums.FlagDelete.NoDelete && d.id_shop == id_shop).FirstOrDefault();
                if (dbInfo == null)
                {
                    item.sysbz += "   不存在此条形码的商品  ";
                    error++;
                    continue;
                }
                else
                {
                    if (dbInfo.flag_delete == (byte)Enums.FlagShopspStop.Deleted)
                    {
                        item.sysbz += "   此条形码的商品已被删除  ";
                        error++;
                        continue;
                    }
                    if (dbInfo.flag_state == (byte)Enums.FlagShopspStop.Stoped)
                    {
                        item.sysbz += "   此条形码的商品已被停用  ";
                        error++;
                        continue;
                    }

                    if (string.IsNullOrEmpty(item.mc))
                    {
                        item.mc = dbInfo.mc;
                    }
                    if (item.dj == null || item.dj == 0)
                    {
                        item.dj = dbInfo.dj_jh.Value;
                    }
                    item.id_shopsp = dbInfo.id;
                    item.barcode   = dbInfo.barcode;
                    item.bm        = dbInfo.bm;
                    item.mc        = dbInfo.mc;
                    item.id_shop   = dbInfo.id_shop;
                    item.id_spfl   = dbInfo.id_spfl;
                    item.dw        = dbInfo.dw;
                    item.dj_jh     = item.dj;
                    if (dbInfo.dj_ls != null)
                    {
                        item.dj_ls = dbInfo.dj_ls.Value;
                    }
                    item.id_kcsp = dbInfo.id_kcsp;
                    if (dbInfo.zhl != null)
                    {
                        item.zhl = dbInfo.zhl.Value;
                    }
                    item.sl_qm        = dbInfo.sl_qm;
                    item.id_sp        = dbInfo.id_sp;
                    item.id_kcsp_ck   = dbInfo.id_kcsp_ck;
                    item.id_shopsp_ck = dbInfo.id_shopsp_ck;
                    if (dbInfo.dj_ps != null)
                    {
                        item.dj_ps = dbInfo.dj_ps.Value;
                    }
                }
                #endregion
            }
            #endregion
            failList    = list.Where(d => d.sysbz != "").ToList();
            successList = list.Where(d => d.sysbz == "").ToList();

            br.Message.Add(String.Format("操作完毕!"));
            br.Success = true;
            br.Data    = new PsShopsp_Import_All()
            {
                SuccessList = successList, FailList = failList, AllList = list
            };
            return(br);
        }
Example #57
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns> 
        public BaseResult<GenericTypeResult<string>> GetHardwareVersion()
        { 
            string response;
            BaseResult<GenericTypeResult<string>> ret = new BaseResult<GenericTypeResult<string>>();
            Stopwatch s = new Stopwatch();

            s.Start();
            response = Connector.Execute(Command.ToString(Commands.WHWV));
            s.Stop();

            Match match = new Regex(@"Hardware Version (\d+).(\d+)(\d+)").Match(response);
            if (match.Success)
            { 
                response = string.Format("{0}.{1}{2}", match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value); 
            }
            ret.ExecutionTime = s.Elapsed;
            ret.Response.Result = response;
            return ret;
        }
Example #58
0
        public ActionResult OutList(string obj)
        {
            BaseResult br = new BaseResult();

            try
            {
                if (!string.IsNullOrEmpty(obj) && obj != "[]")
                {
                    Hashtable               param        = new Hashtable();
                    List <Hashtable>        paramList    = JSON.Deserialize <List <Hashtable> >(obj);
                    List <Td_Sale_Out_Body> body         = new List <Td_Sale_Out_Body>();
                    List <Td_Sale_Out_Body> bodyQuery    = new List <Td_Sale_Out_Body>();
                    Ts_Sale_Order_Log       ts           = new Ts_Sale_Order_Log();//日志
                    ShoppingInfo            shoppinginfo = new ShoppingInfo();
                    if (shoppinginfo != null)
                    {
                        if (shoppinginfo.company_logistics == "")
                        {
                            shoppinginfo.company_logistics = "暂无";
                        }
                        if (shoppinginfo.no_logistics == "")
                        {
                            shoppinginfo.no_logistics = "暂无";
                        }
                        if (shoppinginfo.rq_fh == "")
                        {
                            shoppinginfo.rq_fh = DateTime.Now.ToString();
                        }
                    }
                    long gys            = GetLoginInfo <long>("id_supplier");
                    long id_user        = GetLoginInfo <long>("id_user");
                    long id_user_master = GetLoginInfo <long>("id_user_master");
                    foreach (Hashtable item in paramList)
                    {
                        Td_Sale_Out_Head head = new Td_Sale_Out_Head();
                        head.dh_order = item["dh_order"].ToString();
                        head.id_cgs   = Convert.ToInt32(item["id_cgs"]);
                        head.id_gys   = gys;
                        param.Clear();
                        param["id_gys"] = gys;
                        param["sort"]   = "sl_ck";
                        param["dir"]    = "desc";
                        param.Add("dh", head.dh_order);
                        br = BusinessFactory.Order.GetAll(param);
                        if (br.Data != null)
                        {
                            body.Clear();
                            body      = JSON.Deserialize <List <Td_Sale_Out_Body> >(JSON.Serialize(br.Data));
                            bodyQuery = JSON.Deserialize <List <Td_Sale_Out_Body> >(JSON.Serialize(br.Data));
                            if (head.id_cgs > 0 && !head.dh_order.IsEmpty() && head.id_gys > 0 || body.Count > 0)
                            {
                                int index = 0;
                                foreach (Td_Sale_Out_Body bq in bodyQuery)
                                {
                                    bq.dh_order = bq.dh;
                                    bq.dh       = "";
                                    bq.xh_order = Convert.ToInt16(index++);
                                    bq.sl       = bq.sl - bq.sl_ck;
                                }
                                //for (int i = 0; i < bodyQuery.Count; i++)
                                //{
                                //    //if (bodyQuery[i].sl - bodyQuery[i].sl_ck <= 0)
                                //    //{
                                //    //    bodyQuery.RemoveAt(i);
                                //    //}
                                //    //else
                                //    //{
                                //    //    bodyQuery[i].dh_order = bodyQuery[i].dh;
                                //    //    bodyQuery[i].dh = "";
                                //    //    bodyQuery[i].xh_order = Convert.ToInt16(i++);
                                //    //    bodyQuery[i].sl = bodyQuery[i].sl - bodyQuery[i].sl_ck;
                                //    //    index++;
                                //    //}
                                //    bodyQuery[i].dh_order = bodyQuery[i].dh;
                                //    bodyQuery[i].dh = "";
                                //    bodyQuery[i].xh_order = Convert.ToInt16(i++);
                                //    bodyQuery[i].sl = bodyQuery[i].sl - bodyQuery[i].sl_ck;
                                //}
                                br = BusinessFactory.Utilety.GetNextDH(head, typeof(Td_Sale_Out_Head));
                                if (br.Success)
                                {
                                    ts.id             = BusinessFactory.Utilety.GetNextKey(typeof(Ts_Sale_Order_Log));
                                    ts.id_user        = id_user;
                                    ts.id_user_master = id_user_master;
                                    ts.flag_type      = 4;
                                    head.id_create    = id_user;
                                    head.id_edit      = id_user;
                                    param.Clear();
                                    param.Add("head", head);
                                    param.Add("body", bodyQuery);
                                    param.Add("ShoppingInfo", shoppinginfo);
                                    param.Add("Ts", ts);
                                    param.Add("id_user_master", id_user_master);

                                    br = BusinessFactory.ShippingRecord.Add(param);
                                }
                            }
                        }
                    }
                }
                else
                {
                    br.Success = false;
                    br.Message.Add("无可出库的订单!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                return(Json(br));
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #59
0
        public FileResult Export(string id, string dh)
        {
            BaseResult br      = new BaseResult();
            Hashtable  param   = new Hashtable();
            Hashtable  paramli = new Hashtable();
            Hashtable  param0  = new Hashtable();

            try
            {
                string[] idList = id.Split(',');
                string[] dhList = dh.Split(',');
                //创建Excel文件的对象
                HSSFWorkbook book = new HSSFWorkbook();
                for (int i = 0; i < dhList.Length; i++)
                {
                    param.Clear();
                    param.Add("dh", idList[i]);
                    ParamVessel p = new ParamVessel();
                    p.Add("dh", String.Empty, HandleType.ReturnMsg);
                    param = param.Trim(p);
                    br    = BusinessFactory.Order.Get(param);
                    //ViewData["OrderHead"] = br.Data;
                    //获取订单单体
                    param["sort"] = "sl_ck";
                    param["dir"]  = "desc";
                    br            = BusinessFactory.Order.GetAll(param);
                    //ViewData["OrderbodyList"] = br.Data;
                    //获取出库单头
                    paramli["dh_order"]       = idList[i];
                    paramli["sort"]           = "flag_state asc, rq_fh desc  , rq_create";
                    paramli["dir"]            = "desc";
                    paramli["not_flag_state"] = OrderFlag.Deleted;
                    br = BusinessFactory.ShippingRecord.Get(paramli);
                    var OrderOutHead = br.Data as IList <CySoft.Model.Td.Td_Sale_Out_Head_Query>;
                    var itemhead     = OrderOutHead.Where(m => m.flag_delete == 0 && m.dh == dhList[i]).FirstOrDefault();
                    List <Td_Sale_Out_Head_Query> list2 = (List <Td_Sale_Out_Head_Query>)br.Data;
                    //获取业务流程
                    param0["val"]            = 1;
                    param0["id_user_master"] = GetLoginInfo <long>("id_user_master");
                    br = BusinessFactory.Setting.GetAll(param0);
                    //ViewData["process"] = br.Data;
                    //获取出库单单体
                    paramli["sort"] = "dh";
                    br = BusinessFactory.ShippingRecord.GetAll(paramli);
                    var Orderbody = br.Data as IList <CySoft.Model.Td.Td_Sale_Out_Body_Query>;
                    var item      = Orderbody.Where(m => m.dh == dhList[i]).ToList();

                    #region 导出订单

                    //添加一个sheet
                    ISheet sheet1 = book.CreateSheet(dhList[i]);

                    //设置列宽
                    sheet1.SetColumnWidth(0, 14 * 256);
                    sheet1.SetColumnWidth(1, 25 * 256);
                    sheet1.SetColumnWidth(2, 25 * 256);
                    sheet1.SetColumnWidth(3, 32 * 256);
                    sheet1.SetColumnWidth(4, 14 * 256);
                    sheet1.SetColumnWidth(5, 14 * 256);
                    sheet1.SetColumnWidth(6, 14 * 256);
                    sheet1.SetColumnWidth(7, 14 * 256);

                    //初始化样式
                    ICellStyle mStyle = book.CreateCellStyle();
                    mStyle.Alignment         = HorizontalAlignment.Center;
                    mStyle.VerticalAlignment = VerticalAlignment.Center;
                    mStyle.BorderBottom      = BorderStyle.Thin;
                    mStyle.BorderTop         = BorderStyle.Thin;
                    mStyle.BorderLeft        = BorderStyle.Thin;
                    mStyle.BorderRight       = BorderStyle.Thin;
                    IFont mfont = book.CreateFont();
                    mfont.FontHeight = 10 * 20;
                    mStyle.SetFont(mfont);
                    sheet1.SetDefaultColumnStyle(0, mStyle);
                    sheet1.SetDefaultColumnStyle(1, mStyle);
                    sheet1.SetDefaultColumnStyle(2, mStyle);
                    sheet1.SetDefaultColumnStyle(3, mStyle);
                    sheet1.SetDefaultColumnStyle(4, mStyle);
                    sheet1.SetDefaultColumnStyle(5, mStyle);
                    sheet1.SetDefaultColumnStyle(6, mStyle);
                    sheet1.SetDefaultColumnStyle(7, mStyle);

                    //第一行
                    IRow  row  = sheet1.CreateRow(0);
                    ICell cell = row.CreateCell(0);
                    cell.SetCellValue("出库/发货记录");
                    ICellStyle style = book.CreateCellStyle();
                    style.Alignment         = HorizontalAlignment.Center;
                    style.VerticalAlignment = VerticalAlignment.Center;
                    IFont font = book.CreateFont();
                    font.FontHeight = 20 * 20;
                    style.SetFont(font);

                    cell.CellStyle = style;
                    sheet1.AddMergedRegion(new CellRangeAddress(0, 0, 0, 7));
                    sheet1.GetRow(0).Height = 40 * 20;

                    //第二行
                    IRow row1 = sheet1.CreateRow(1);
                    row1.CreateCell(0).SetCellValue("出库编号");
                    row1.CreateCell(1).SetCellValue(dh);
                    row1.CreateCell(2).SetCellValue("出库日期");
                    row1.CreateCell(3).SetCellValue(Convert.ToDateTime(itemhead.rq_create).ToString("yyyy-MM-dd HH:mm"));
                    row1.CreateCell(4).SetCellValue("发货日期");
                    var rq_fh_logistics = Convert.ToDateTime(itemhead.rq_fh_logistics);//;
                    row1.CreateCell(6).SetCellValue(rq_fh_logistics < Convert.ToDateTime("1900-01-02") ? "无发货日期" : rq_fh_logistics.ToString("yyyy-MM-dd HH:mm"));
                    sheet1.AddMergedRegion(new CellRangeAddress(1, 1, 4, 5));
                    sheet1.AddMergedRegion(new CellRangeAddress(1, 1, 6, 7));
                    sheet1.GetRow(1).Height = 28 * 20;

                    //第三行
                    IRow row2 = sheet1.CreateRow(2);
                    row2.CreateCell(0).SetCellValue("物流公司");
                    row2.CreateCell(1).SetCellValue(itemhead.company_logistics);//
                    row2.CreateCell(2).SetCellValue("状态");
                    var flag_state = string.Empty;

                    switch (itemhead.flag_state)
                    {
                    case OrderFlag.Invalided:
                        flag_state = "已作废";
                        break;

                    case OrderFlag.Submitted:
                        flag_state = "已提交";
                        break;

                    case OrderFlag.OrderCheck:
                        flag_state = "订单审核";
                        break;

                    case OrderFlag.FinanceCheck:
                        flag_state = "财务审核";
                        break;

                    case OrderFlag.WaitOutputCheck:
                        flag_state = "待出库审核";
                        break;

                    case OrderFlag.Outbounded:
                        flag_state = "已出库";
                        break;

                    case OrderFlag.WaitDelivery:
                        flag_state = "待发货";
                        break;

                    case OrderFlag.Delivered:
                        flag_state = "已发货";
                        break;

                    case OrderFlag.Receipted:
                        flag_state = "已收货";
                        break;

                    case OrderFlag.Deleted:
                        flag_state = "已删除";
                        break;
                    }

                    /* if (itemhead.flag_state == CySoft.Model.Flags.OrderFlag.Delivered)
                     * {
                     *   flag_state = "未签收";
                     * }
                     * else
                     *   flag_state = "已签收";*/
                    row2.CreateCell(3).SetCellValue(flag_state);
                    row2.CreateCell(4).SetCellValue("物流单号");
                    row2.CreateCell(6).SetCellValue(itemhead.no_logistics);
                    sheet1.AddMergedRegion(new CellRangeAddress(2, 2, 4, 5));
                    sheet1.AddMergedRegion(new CellRangeAddress(2, 2, 6, 7));
                    sheet1.GetRow(2).Height = 28 * 20;

                    //第四行
                    IRow  row3  = sheet1.CreateRow(3);
                    ICell cell3 = row3.CreateCell(0);
                    cell3.SetCellValue("商品明细");
                    cell3.CellStyle = style;
                    sheet1.AddMergedRegion(new CellRangeAddress(3, 3, 0, 7));
                    sheet1.GetRow(3).Height = 40 * 20;

                    //第五行
                    IRow row4 = sheet1.CreateRow(4);
                    row4.CreateCell(0).SetCellValue("序号");
                    row4.CreateCell(1).SetCellValue("商品编码");
                    row4.CreateCell(2).SetCellValue("商品名称");
                    row4.CreateCell(3).SetCellValue("商品规格");
                    row4.CreateCell(4).SetCellValue("数量");
                    row4.CreateCell(5).SetCellValue("计量单位");
                    row4.CreateCell(6).SetCellValue("备注");
                    sheet1.AddMergedRegion(new CellRangeAddress(4, 4, 6, 7));
                    sheet1.GetRow(4).Height = 28 * 20;

                    //将数据逐步写入sheet1各个行

                    for (int k = 0; k < item.Count; k++)
                    {
                        IRow rowtemp = sheet1.CreateRow(k + 5);
                        rowtemp.CreateCell(0).SetCellValue(k + 1);
                        rowtemp.CreateCell(1).SetCellValue(item[k].GoodsBm);
                        rowtemp.CreateCell(2).SetCellValue(item[k].GoodsName);
                        rowtemp.CreateCell(3).SetCellValue(item[k].formatname);
                        rowtemp.CreateCell(4).SetCellValue(Decimal.Round((decimal)item[k].sl, 2).ToString());
                        rowtemp.CreateCell(5).SetCellValue(item[k].unit);
                        rowtemp.CreateCell(6).SetCellValue(item[k].remark);
                        sheet1.AddMergedRegion(new CellRangeAddress(k + 5, k + 5, 6, 7));
                        sheet1.GetRow(k + 5).Height = 28 * 20;
                    }
                }


                // 写入到客户端
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                book.Write(ms);
                ms.Seek(0, SeekOrigin.Begin);
                string title = "出库/发货记录-" + dh;
                if (dhList.Length > 1)
                {
                    title = "批量导出出库/发货记录" + DateTime.Now.ToString("yyyyMMddHHmmss");
                }
                return(File(ms, "application/vnd.ms-excel", title + ".xls"));

                #endregion
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #60
0
 public abstract List <byte[]> ReadRow(BaseResult rs);