Ejemplo n.º 1
0
        public ActionResult Edit(string cid)
        {
            //省份
            ViewBag.Province = BaseDataService.GetAllProvince();
            //默认承运商
            ViewBag.Carrier = CarrierService.GetCarrierByRule("", 1);    //只显示使用中的数据
            //默认仓库
            ViewBag.Storage = StorageService.GetStorageByRule("", 1);    //只显示使用中的数据
            //客户信息
            ViewBag.Customer = CustomerService.GetCustomerByRule("", 1); //只显示使用中的数据

            //收货方类型
            ViewBag.ReceiverList = BaseDataService.GetBaseDataAll().Where(t => t.PCode == "Reveiver00" && t.Status == 1).ToList();
            if (!string.IsNullOrEmpty(cid))
            {
                ReceiverEntity entity = ReceiverService.GetReceiverEntityById(cid.ToLong(0));
                entity.Url       = UrlPar;
                ViewBag.Receiver = entity;
            }
            else
            {
                ViewBag.Receiver = new ReceiverEntity();
            }

            return(View());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据客户ID 查询对应的门店信息
        /// </summary>
        /// <param name="rid"></param>
        /// <returns></returns>
        public JsonResult GetReceiverByCustomerID(int customerID, string customerName = "")
        {
            List <ReceiverEntity> outList = new List <ReceiverEntity>();
            List <ReceiverEntity> list    = ReceiverService.GetReceiverByCustomerID(customerID);

            if (list != null && list.Count > 0)
            {
                if (!string.IsNullOrEmpty(customerName))
                {
                    var v = from d in list where d.ReceiverName.Contains(customerName) select d;

                    if (v != null)
                    {
                        foreach (var k in v)
                        {
                            ReceiverEntity model = new ReceiverEntity();
                            model.ReceiverID   = k.ReceiverID;
                            model.ReceiverName = k.ReceiverName;
                            outList.Add(model);
                        }
                    }
                }
                else
                {
                    foreach (ReceiverEntity entity in list)
                    {
                        outList.Add(entity);
                    }
                }
            }

            return(Json(outList));
        }
Ejemplo n.º 3
0
        private static ReceiverInfo TranslateReceiverInfo(ReceiverEntity entity)
        {
            ReceiverInfo info = new ReceiverInfo();

            if (entity != null)
            {
                info.CustomerID       = entity.CustomerID;
                info.ReceiverType     = entity.ReceiverType;
                info.DefaultCarrierID = entity.DefaultCarrierID;
                info.DefaultStorageID = entity.DefaultStorageID;
                info.ProvinceID       = entity.ProvinceID;
                info.CityID           = entity.CityID;
                info.Address          = entity.Address;
                info.Remark           = entity.Remark;

                info.OperatorID   = entity.OperatorID;
                info.ReceiverName = entity.ReceiverName;
                info.ReceiverNo   = entity.ReceiverNo;
                info.Status       = entity.Status;
                info.CreateDate   = entity.CreateDate;
                info.ChangeDate   = entity.ChangeDate;
                info.ReceiverID   = entity.ReceiverID;
            }
            return(info);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 门店模糊查询
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public JsonResult SearchByName(string name)
        {
            List <ReceiverEntity> list         = new List <ReceiverEntity>();
            List <ReceiverEntity> reveiverList = ReceiverService.GetReceiverAll(false);

            if (reveiverList != null && reveiverList.Count > 0)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    var v = from d in reveiverList where d.ReceiverName.Contains(name) select d;

                    if (v != null)
                    {
                        foreach (var k in v)
                        {
                            ReceiverEntity model = new ReceiverEntity();
                            model.ReceiverID   = k.ReceiverID;
                            model.ReceiverName = k.ReceiverName;
                            list.Add(model);
                        }
                    }
                }
                else
                {
                    foreach (ReceiverEntity entity in reveiverList)
                    {
                        list.Add(entity);
                    }
                }
            }
            return(Json(list));
        }
Ejemplo n.º 5
0
        public static ReceiverEntity GetReceiverById(long gid)
        {
            ReceiverEntity     result = new ReceiverEntity();
            ReceiverRepository mr     = new ReceiverRepository();
            ReceiverInfo       info   = mr.GetReceiverByKey(gid);

            result = TranslateReceiverEntity(info);
            return(result);
        }
Ejemplo n.º 6
0
 public void Modify(ReceiverEntity Receiver)
 {
     if (Receiver != null)
     {
         Receiver.OperatorID = CurrentUser.UserID;
     }
     ReceiverService.ModifyReceiver(Receiver);
     Response.Redirect("/Receiver/Index?" + Receiver.Url);
 }
Ejemplo n.º 7
0
        public static ReceiverEntity GetReceiverEntityById(long cid)
        {
            ReceiverEntity     result = new ReceiverEntity();
            ReceiverRepository mr     = new ReceiverRepository();
            ReceiverInfo       info   = mr.GetReceiverByKey(cid);

            if (info != null)
            {
                result = TranslateReceiverEntity(info);
                //获取联系人信息
                result.listContact = ContactService.GetContactByRule(UnionType.Receiver.ToString(), info.ReceiverID);
            }
            return(result);
        }
Ejemplo n.º 8
0
        public static List <ReceiverEntity> GetReceiverInfoPager(PagerInfo pager)
        {
            List <ReceiverEntity> all    = new List <ReceiverEntity>();
            ReceiverRepository    mr     = new ReceiverRepository();
            List <ReceiverInfo>   miList = mr.GetAllReceiverInfoPager(pager);

            if (!miList.IsEmpty())
            {
                foreach (ReceiverInfo mInfo in miList)
                {
                    ReceiverEntity carEntity = TranslateReceiverEntity(mInfo);
                    all.Add(carEntity);
                }
            }
            return(all);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="no">编号</param>
        /// <param name="receiverType">收货类型</param>
        /// <param name="status">状态 1:使用中 0:已删除</param>
        /// <returns></returns>
        public static List <ReceiverEntity> GetReceiverByRule(string name, string no, string receiverType, int status)
        {
            List <ReceiverEntity> all    = new List <ReceiverEntity>();
            ReceiverRepository    mr     = new ReceiverRepository();
            List <ReceiverInfo>   miList = mr.GetReceiverByRule(name, no, receiverType, status);

            if (!miList.IsEmpty())
            {
                foreach (ReceiverInfo mInfo in miList)
                {
                    ReceiverEntity ReceiverEntity = TranslateReceiverEntity(mInfo);
                    all.Add(ReceiverEntity);
                }
            }

            return(all);
        }
Ejemplo n.º 10
0
        public static List <ReceiverEntity> GetReceiverByKeys(string ids)
        {
            List <ReceiverEntity> all    = new List <ReceiverEntity>();
            ReceiverRepository    mr     = new ReceiverRepository();
            List <ReceiverInfo>   miList = mr.GetReceiverByKeys(ids);

            if (!miList.IsEmpty())
            {
                foreach (ReceiverInfo mInfo in miList)
                {
                    ReceiverEntity entity = TranslateReceiverEntity(mInfo);
                    all.Add(entity);
                }
            }

            return(all);
        }
Ejemplo n.º 11
0
        public static List <ReceiverEntity> GetReceiverInfoByRule(string name, string receiverType, int customerID, int status, PagerInfo pager)
        {
            List <ReceiverEntity> all    = new List <ReceiverEntity>();
            ReceiverRepository    mr     = new ReceiverRepository();
            List <ReceiverInfo>   miList = mr.GetReceiverInfoByRule(name, receiverType, customerID, status, pager);

            if (!miList.IsEmpty())
            {
                foreach (ReceiverInfo mInfo in miList)
                {
                    ReceiverEntity storeEntity = TranslateReceiverEntity(mInfo);
                    all.Add(storeEntity);
                }
            }

            return(all);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 根据收货人ID 查询对应的联系人信息
        /// </summary>
        /// <param name="rid"></param>
        /// <returns></returns>
        public JsonResult GetReceiverByGoodsID(int rid)
        {
            ContactModel   contact = new ContactModel();
            ReceiverEntity entity  = ReceiverService.GetReceiverEntityById(long.Parse(rid.ToString()));

            if (entity != null)
            {
                List <ContactEntity> list = entity.listContact;
                if (list != null && list.Count > 0)
                {
                    contact.ContactName = list[0].ContactName;
                    contact.Mobile      = string.IsNullOrEmpty(list[0].Mobile) ? list[0].Telephone : list[0].Mobile;
                }
                contact.Address = entity.Address;
            }
            return(Json(contact));
        }
Ejemplo n.º 13
0
        private static ReceiverEntity TranslateReceiverEntity(ReceiverInfo info, bool isRead = true)
        {
            ReceiverEntity entity = new ReceiverEntity();

            if (info != null)
            {
                entity.CustomerID       = info.CustomerID;
                entity.ReceiverType     = info.ReceiverType;
                entity.DefaultCarrierID = info.DefaultCarrierID;
                entity.DefaultStorageID = info.DefaultStorageID;
                entity.ProvinceID       = info.ProvinceID;
                entity.CityID           = info.CityID;
                entity.Address          = info.Address;
                entity.Remark           = info.Remark;

                entity.OperatorID   = info.OperatorID;
                entity.ReceiverName = info.ReceiverName;
                entity.ReceiverNo   = info.ReceiverNo;
                entity.Status       = info.Status;
                entity.CreateDate   = info.CreateDate;
                entity.ChangeDate   = info.ChangeDate;
                entity.ReceiverID   = info.ReceiverID;

                if (isRead)
                {
                    City     city     = BaseDataService.GetAllCity().FirstOrDefault(t => t.CityID == info.CityID) ?? new City();
                    Province province = BaseDataService.GetAllProvince().FirstOrDefault(t => t.ProvinceID == info.ProvinceID) ?? new Province();
                    entity.province = province;
                    entity.city     = city;
                    entity.customer = new CustomerEntity();
                    entity.customer = CustomerService.GetCustomerById(info.CustomerID);

                    CarrierEntity carrier = CarrierService.GetCarrierById(info.DefaultCarrierID);
                    entity.Carrier = carrier;

                    StorageEntity storage = StorageService.GetStorageEntityById(info.DefaultStorageID);
                    entity.Storage = storage;
                }
                //获取联系人信息
                entity.listContact = ContactService.GetContactByRule(UnionType.Receiver.ToString(), info.ReceiverID);
            }

            return(entity);
        }
Ejemplo n.º 14
0
        public static List <ReceiverEntity> GetReceiverAll(bool isRead = true)
        {
            List <ReceiverEntity> all    = new List <ReceiverEntity>();
            ReceiverRepository    mr     = new ReceiverRepository();
            List <ReceiverInfo>   miList = Cache.Get <List <ReceiverInfo> >("ReceiverALL");

            if (miList.IsEmpty())
            {
                miList = mr.GetAllReceiver();
                Cache.Add("ReceiverALL", miList);
            }
            if (!miList.IsEmpty())
            {
                foreach (ReceiverInfo mInfo in miList)
                {
                    ReceiverEntity ReceiverEntity = TranslateReceiverEntity(mInfo, isRead);
                    all.Add(ReceiverEntity);
                }
            }

            return(all);
        }
Ejemplo n.º 15
0
        public static List <ReceiverEntity> GetReceiverByCustomerID(int customerID)
        {
            List <ReceiverEntity> all    = new List <ReceiverEntity>();
            ReceiverRepository    mr     = new ReceiverRepository();
            List <ReceiverInfo>   miList = null;//Cache.Get<List<ReceiverInfo>>("GetReceiverByCustomerID" + customerID);

            if (miList.IsEmpty())
            {
                miList = mr.GetReceiverByCustomerID(customerID);
                Cache.Add("GetReceiverByCustomerID" + customerID, miList);
            }
            if (!miList.IsEmpty())
            {
                foreach (ReceiverInfo mInfo in miList)
                {
                    ReceiverEntity ReceiverEntity = TranslateReceiverEntity(mInfo, false);
                    all.Add(ReceiverEntity);
                }
            }

            return(all);
        }
Ejemplo n.º 16
0
        public static bool ModifyReceiver(ReceiverEntity entity)
        {
            long result = 0;

            if (entity != null)
            {
                ReceiverRepository mr = new ReceiverRepository();

                ReceiverInfo ReceiverInfo = TranslateReceiverInfo(entity);

                ContactJsonEntity jsonlist = null;
                if (!string.IsNullOrEmpty(entity.ContactJson))
                {
                    try
                    {
                        jsonlist = (ContactJsonEntity)JsonHelper.FromJson(entity.ContactJson, typeof(ContactJsonEntity));
                    }
                    catch (Exception ex)
                    {
                        string str = ex.ToString();
                    }
                }

                if (entity.ReceiverID > 0)
                {
                    ReceiverInfo.ReceiverID = entity.ReceiverID;
                    ReceiverInfo.ChangeDate = DateTime.Now;
                    result = mr.ModifyReceiver(ReceiverInfo);
                }
                else
                {
                    ReceiverInfo.ChangeDate = DateTime.Now;
                    ReceiverInfo.CreateDate = DateTime.Now;
                    result = mr.CreateNew(ReceiverInfo);
                }

                #region 更新联系人信息
                if (jsonlist != null)
                {
                    List <ContactJson> list = jsonlist.listContact;
                    if (list != null && list.Count > 0)
                    {
                        foreach (ContactJson cc in list)
                        {
                            ContactRepository cr      = new ContactRepository();
                            ContactInfo       contact = new ContactInfo();
                            contact.ContactName = cc.ContactName;
                            contact.Mobile      = cc.Mobile;
                            contact.Telephone   = cc.Telephone;
                            contact.Email       = cc.Email;
                            contact.Remark      = cc.Remark;
                            contact.UnionType   = UnionType.Receiver.ToString();//客户
                            if (cc.ContactID > 0)
                            {
                                contact.ContactID  = cc.ContactID;
                                contact.UnionID    = entity.ReceiverID;
                                contact.ChangeDate = DateTime.Now;
                                cr.ModifyContact(contact);
                            }
                            else
                            {
                                contact.UnionID    = entity.ReceiverID > 0 ? entity.ReceiverID : result;
                                contact.CreateDate = DateTime.Now;
                                contact.ChangeDate = DateTime.Now;
                                cr.CreateNew(contact);
                            }
                        }
                    }
                }
                #endregion

                List <ReceiverInfo> miList = mr.GetAllReceiver();//刷新缓存
                Cache.Add("ReceiverALL", miList);

                Cache.Add("GetReceiverByCustomerID" + entity.CustomerID, miList);
            }
            return(result > 0);
        }
Ejemplo n.º 17
0
 public ReceiverSaveCommand(IDataSourceConfig dataSource, ReceiverEntity receiver)
 {
     _rowMapper  = new ReceiverRowMapper();
     _dataSource = dataSource;
     _receiver   = receiver;
 }