Пример #1
0
        public static bool ModifyContact(ContactEntity entity)
        {
            int result = 0;

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

                ContactInfo info = TranslateContactInfo(entity);


                if (entity.ContactID > 0)
                {
                    result = mr.ModifyContact(info);
                }
                else
                {
                    info.CreateDate = DateTime.Now;
                    result          = mr.CreateNew(info);
                }

                List <ContactInfo> miList = mr.GetAllContact();//刷新缓存
                Cache.Add("ContactALL", miList);
            }
            return(result > 0);
        }
Пример #2
0
        public static void GetAllTest()
        {
            BaseDataRepository   mr          = new BaseDataRepository();
            DataSet              ds          = mr.GetAllTest();
            DataTable            dt          = ds.Tables[0];
            List <Province>      proList     = GetAllProvince();
            List <City>          cList       = GetAllCity();
            List <CarrierEntity> carrList    = CarrierService.GetCarrierAll();
            List <StorageEntity> storageList = StorageService.GetStorageAll();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    //ReceiverRepository mrs = new ReceiverRepository();
                    //ReceiverInfo info = new ReceiverInfo();
                    //List<CustomerEntity> listCus = CustomerService.GetCustomerByRule(dr["客户名称"].ToString(), -1);
                    //if (listCus != null && listCus.Count > 0)
                    //{
                    //    info.CustomerID = listCus[0].CustomerID;
                    //}
                    //info.ReceiverName = dr["门店名称"].ToString();
                    //info.ReceiverNo = dr["门店编号"].ToString();
                    //info.Address = dr["门店地址"].ToString();
                    //Province pInfo = proList.Find(p => p.ProvinceName.Equals(dr["所属省份"].ToString().Replace("省", "").Replace("市", "")));
                    //info.ProvinceID = pInfo != null ? pInfo.ProvinceID : 0;
                    //info.ReceiverType = "门店";
                    //City cInfo = cList.Find(p => p.CityName.Equals(dr["所属市区"].ToString().Replace("市", "")));
                    //info.CityID = cInfo != null ? cInfo.CityID : 0;
                    //info.Address = dr["门店地址"].ToString();
                    //info.OperatorID = 1;
                    //info.Remark = dr["门店描述"].ToString();
                    //CarrierEntity centity = carrList.Find(p => p.CarrierShortName.Equals(dr["默认承运商简称"].ToString()));
                    //info.DefaultCarrierID = centity != null ? centity.CarrierID : 0;
                    //StorageEntity sEntity = storageList.Find(p => p.StorageName.Equals(dr["默认出库仓"]));
                    //info.DefaultStorageID = sEntity != null ? sEntity.StorageID : 0;
                    //info.Status = 1;
                    //info.CreateDate = DateTime.Now;
                    //info.ChangeDate = DateTime.Now;
                    //long id = mrs.CreateNew(info);

                    List <ReceiverEntity> list = ReceiverService.GetReceiverByRule(dr["门店名称"].ToString(), "", "", -1);
                    long id = list != null && list.Count > 0 ? list[0].ReceiverID : 0;

                    ContactRepository cr      = new ContactRepository();
                    ContactInfo       contact = new ContactInfo();
                    if (!string.IsNullOrEmpty(dr["联系人"].ToString()) || !string.IsNullOrEmpty(dr["联系方式"].ToString()))
                    {
                        contact.ContactName = dr["联系人"].ToString();
                        contact.Mobile      = dr["联系方式"].ToString();
                        contact.Telephone   = dr["联系方式"].ToString();
                        contact.Email       = "";
                        contact.Remark      = "";
                        contact.UnionType   = UnionType.Receiver.ToString();//客户
                        contact.UnionID     = id;
                        contact.CreateDate  = DateTime.Now;
                        contact.ChangeDate  = DateTime.Now;
                        cr.CreateNew(contact);
                    }
                }
            }
        }
Пример #3
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);
        }
Пример #4
0
        public static bool ModifyStorage(StorageEntity StorageEntity)
        {
            long result          = 0;
            StorageRepository mr = new StorageRepository();

            if (StorageEntity != null)
            {
                StorageInfo StorageInfo = TranslateStorageInfo(StorageEntity);

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

                if (StorageEntity.StorageID > 0)
                {
                    StorageInfo.ChangeDate = DateTime.Now;
                    result = mr.ModifyStorage(StorageInfo);
                }
                else
                {
                    StorageInfo.CreateDate = DateTime.Now;
                    StorageInfo.ChangeDate = DateTime.Now;
                    result = mr.CreateNew(StorageInfo);
                }

                #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.Storage.ToString();//仓库
                            if (cc.ContactID > 0)
                            {
                                contact.ContactID  = cc.ContactID;
                                contact.UnionID    = StorageEntity.StorageID;
                                contact.ChangeDate = DateTime.Now;
                                cr.ModifyContact(contact);
                            }
                            else
                            {
                                contact.UnionID    = StorageEntity.StorageID > 0 ? StorageEntity.StorageID : result;
                                contact.CreateDate = DateTime.Now;
                                contact.ChangeDate = DateTime.Now;
                                cr.CreateNew(contact);
                            }
                        }
                    }
                }
                #endregion
            }
            List <StorageInfo> miList = mr.GetAllstorage();
            Cache.Add("StorageALL", miList);
            return(result > 0);
        }