/// <summary>
 /// 移除地址本
 /// </summary>
 /// <param name="addressBook">地址本</param>
 public void RemoveAddressBook(AddressBook addressBook)
 {
     if (addressBook == null)
         throw new ArgumentNullException("AddressBook is null");
     IUnitOfWork unitOfWork = _addressBookRepository.UnitOfWork;
     _addressBookRepository.Add(addressBook);
     //complete changes in this unit of work
     unitOfWork.Commit();
 }
 /// <summary>
 /// 修改地址本
 /// </summary>
 /// <param name="addressBook">地址本</param>
 public void ModifyAddressBook(AddressBook addressBook)
 {
     if (addressBook == null)
         throw new ArgumentNullException("AddressBook is null");
     IUnitOfWork unitOfWork = _addressBookRepository.UnitOfWork;
     _addressBookRepository.Modify(addressBook);
     //complete changes in this unit of work
     unitOfWork.CommitAndRefreshChanges();
 }
        /// <summary>
        /// 用户输入验证
        /// </summary>
        /// <param name="UID"></param>
        /// <param name="DID"></param>
        protected void AddRessBook(string UID,string DID)
        {
            if (Txt_DeliverName.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('公司名称不能为空!')", true);
                Txt_DeliverName.Focus();
            }
            else if (Txt_DeliverAddress.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('地址不能为空!')", true);
                Txt_DeliverAddress.Focus();
            }
            else if (Txt_DeliverCountry.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('国家不能为空!')", true);
                Txt_DeliverCountry.Focus();
            }
            else if (Txt_DeliverRegion.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('地区不能为空!')", true);
                Txt_DeliverRegion.Focus();
            }
            else if (Txt_DeliverZipCode.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('邮编不能为空!')", true);
                Txt_DeliverZipCode.Focus();
            }

            else if (Txt_DeliverContactor.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('联系人不能为空!')", true);
                Txt_DeliverContactor.Focus();
            }
            else if (Txt_DeliverTel.Text.Trim() == "")
            {
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('不能为空!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('电话号码不能为空!')", true);
                Txt_DeliverTel.Focus();
            }
            else
            {
                if (!RTel.IsMatch(Txt_DeliverTel.Text.Trim()))
                {
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('电话号码格式不正确!')</script>");
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('电话号码格式不正确!')", true);
                    Txt_DeliverTel.Focus();
                }
                else
                {
                    address = new AddressBook();
                    address.AID = Guid.NewGuid();
                    if (UID != "")
                    {
                        address.UID = Guid.Parse(UID);
                    }
                    if (DID != "")
                    {
                        address.DID = Guid.Parse(DID);
                    }
                    address.Name = Txt_DeliverName.Text.Trim().ToUpper();
                    address.Address = Txt_DeliverAddress.Text.Trim().ToUpper();
                    address.CountryCode = CountrySwitch(Txt_DeliverCountry.Text.Trim().ToUpper());
                    address.Provience = Txt_DeliverProvince.Text.Trim().ToUpper();
                    address.RegionCode = RegionSwitch(Txt_DeliverRegion.Text.Trim().ToUpper());
                    address.PostCode = Txt_DeliverZipCode.Text.Trim().ToUpper();
                    address.ContactorName = Txt_DeliverContactor.Text.Trim().ToUpper();
                    address.Phone = Txt_DeliverTel.Text.Trim().ToUpper();
                    address.AddressType = int.Parse(ddl_AddressBookType.SelectedValue);
                    address.CreateTime = DateTime.Now;
                    address.UpdateTime = DateTime.Now;
                    address.Operator = "admin";
                    _addressbookservice.AddAddressBook(address);
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!')</script>");
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('添加成功!')", true);
                    InitialControl(this.Controls);
                    Session.Remove("User");
                    Session.Remove("Depar");
                }
            }
        }
Example #4
0
        /// <summary>
        /// 页面控件赋值
        /// </summary>
        protected void Evaluate()
        {
            if (Session["HAWB"] != null)//判断信息页面传的值是否为空
            {
                hawb = (HAWB)Session["HAWB"];
            }
            if (Session["DeliverBook"] != null)//判断选择历史按钮是否又记录
            {
                Addbook = (AddressBook)Session["DeliverBook"];
            }
            if (Addbook != null)
            {
                Txt_DeliverName.Text = Addbook.Name;
                Txt_DeliverAddress.Text = Addbook.Address;
                foreach (CountryCode countrycode in listcountry)
                {
                    if (countrycode.CountryCode1 == Addbook.CountryCode)
                    {
                        Txt_DeliverCountry.Text = countrycode.CountryName;
                        break;
                    }
                }
                foreach (RegionCode regioncode in listregion)
                {
                    if (regioncode.RegionCode1 == Addbook.RegionCode)
                    {
                        Txt_DeliverRegion.Text = regioncode.RegionName;
                        break;
                    }
                }
                Txt_DeliverProvince.Text = Addbook.Provience;
                Txt_DeliverZipCode.Text = Addbook.PostCode;
                Txt_DeliverContactor.Text = Addbook.ContactorName;
                Txt_DeliverTel.Text = Addbook.Phone;
            }
            else
            {
                string CompanyCode = string.Empty;
                string DepCode = string.Empty;
                if (Session["compayCode"] != null)
                {
                    CompanyCode = Session["compayCode"].ToString();
                }
                if (Session["DepCode"] != null)
                {
                    DepCode = Session["DepCode"].ToString();
                }
                if (!string.IsNullOrEmpty(DepCode) && !string.IsNullOrEmpty(CompanyCode))
                {
                    IList<AddressBook> ressbook = _deparservice.FindAllForwarderAddressesByDepCodeAndCompanyCode(DepCode, CompanyCode);

                    if (ressbook != null)
                    {
                        foreach (AddressBook address in ressbook)
                        {
                            if (address.AddressType == 2)
                            {
                                Txt_DeliverName.Text = address.Name;
                                Txt_DeliverAddress.Text = address.Address;
                                Txt_DeliverCountry.Text = CountrySwitch(address.CountryCode,1);
                                Txt_DeliverRegion.Text = RegionSwitch(address.RegionCode, 1);
                                Txt_DeliverProvince.Text = address.Provience;
                                Txt_DeliverZipCode.Text = address.PostCode;
                                Txt_DeliverContactor.Text = address.ContactorName;
                                Txt_DeliverTel.Text = address.Phone;
                                break;
                            }

                        }
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// 保存新地址
        /// </summary>
        /// <param name="type">信息类型 0:发件人,1:收件人,2:交付人</param>
        protected void Address(int type)
        {
            AddressBook address = new AddressBook();
            if (Txt_Account2.Text.Trim().ToUpper() != "" && Txt_Account1.Text.Trim().ToUpper() != "")
            {
                Department deparment = _departmentservice.FindDepartmentByDepCodeAndCompanyCode(Txt_Account2.Text.Trim().ToUpper(), Txt_Account1.Text.Trim().ToUpper());
                address.AID = Guid.NewGuid();
                address.DID = deparment.DID;
                if (TextEmpty(type))
                {
                    if (type == 0)
                    {

                        address.Name = Txt_ShipperName.Text.Trim().ToUpper();
                        address.Address = Txt_ShipperAddress.Text.Trim().ToUpper();
                        address.CountryCode = CountrySwitch(Txt_ShipperCountry.Text.Trim().ToUpper());
                        address.RegionCode = RegionSwitch(Txt_ShipperRegion.Text.Trim().ToUpper());
                        address.Provience = Txt_ShipperProvince.Text.Trim().ToUpper();
                        address.PostCode = Txt_ShipperZipCode.Text.Trim().ToUpper();
                        address.ContactorName = Txt_ShipperContactor.Text.Trim().ToUpper();
                        address.Phone = Txt_ShipperTel.Text.Trim().ToUpper();
                        address.CreateTime = DateTime.Now;
                        address.UpdateTime = DateTime.Now;
                        address.AddressType = 0;
                        address.Operator = "Admin";
                        _addressbookservice.AddAddressBook(address);
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('保存成功!')", true);
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功!')</script>");
                        btn_Addressbox.Visible = false;

                    }
                    else if (type == 1)
                    {
                        address.Name = Txt_ConsigneeName.Text.Trim().ToUpper();
                        address.Address = Txt_ConsigneeAddress.Text.Trim().ToUpper();
                        address.CountryCode = CountrySwitch(Txt_ConsigneeCountry.Text.Trim().ToUpper());
                        address.RegionCode = RegionSwitch(Txt_ConsigneeRegion.Text.Trim().ToUpper());
                        address.Provience = Txt_ConsigneeProvince.Text.Trim().ToUpper();
                        address.PostCode = Txt_ConsigneeZipCode.Text.Trim().ToUpper();
                        address.ContactorName = Txt_ConsigneeContactor.Text.Trim().ToUpper();
                        address.Phone = Txt_ConsigneeTel.Text.Trim().ToUpper();
                        address.CreateTime = DateTime.Now;
                        address.UpdateTime = DateTime.Now;
                        address.AddressType = 1;
                        address.Operator = "Admin";
                        _addressbookservice.AddAddressBook(address);
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('保存成功!')", true);
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功!')</script>");
                        btn_ConsigneeAddress.Visible = false;
                    }
                    else
                    {
                        address.Name = Txt_DeliverName.Text.Trim().ToUpper();
                        address.Address = Txt_DeliverAddress.Text.Trim().ToUpper();
                        address.CountryCode = CountrySwitch(Txt_DeliverCountry.Text.Trim().ToUpper());
                        address.RegionCode = RegionSwitch(Txt_DeliverRegion.Text.Trim().ToUpper());
                        address.Provience = Txt_DeliverProvince.Text.Trim().ToUpper();
                        address.PostCode = Txt_DeliverZipCode.Text.Trim().ToUpper();
                        address.ContactorName = Txt_DeliverContactor.Text.Trim().ToUpper();
                        address.Phone = Txt_DeliverTel.Text.Trim().ToUpper();
                        address.CreateTime = DateTime.Now;
                        address.UpdateTime = DateTime.Now;
                        address.AddressType = 2;
                        address.Operator = "Admin";
                        _addressbookservice.AddAddressBook(address);
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('保存成功!')", true);
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功!')</script>");
                        btn_DeliverAddress.Visible = false;
                    }
                }
            }
        }