Esempio n. 1
0
        private void btnAddShipper_Click(object sender, EventArgs e)
        {
            ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
            ShippersInfo defaultGetGoodsShipperBysupplierId = SalesHelper.GetDefaultGetGoodsShipperBysupplierId(0);
            ShippersInfo shippersInfo = new ShippersInfo();

            shippersInfo.ShipperTag  = this.txtShipperTag.Text.Trim();
            shippersInfo.ShipperName = this.txtShipperName.Text.Trim();
            if (!this.ddlReggion.GetSelectedRegionId().HasValue)
            {
                this.ShowMsg("请选择地区", false);
            }
            else
            {
                shippersInfo.RegionId          = this.ddlReggion.GetSelectedRegionId().Value;
                shippersInfo.Address           = this.txtAddress.Text.Trim();
                shippersInfo.CellPhone         = this.txtCellPhone.Text.Trim();
                shippersInfo.TelPhone          = this.txtTelPhone.Text.Trim();
                shippersInfo.Zipcode           = this.txtZipcode.Text.Trim();
                shippersInfo.IsDefault         = (defaultOrFirstShipper == null || !defaultOrFirstShipper.IsDefault);
                shippersInfo.IsDefaultGetGoods = (defaultGetGoodsShipperBysupplierId == null || !defaultGetGoodsShipperBysupplierId.IsDefaultGetGoods);
                shippersInfo.Remark            = this.txtRemark.Text.Trim();
                shippersInfo.WxOpenId          = Globals.StripAllTags(this.txtWxOpenId.Text.Trim());
                shippersInfo.SupplierId        = 0;
                shippersInfo.Longitude         = Math.Round(double.Parse(string.IsNullOrEmpty(this.hfLongitude.Value) ? "0" : this.hfLongitude.Value), 6);
                shippersInfo.Latitude          = Math.Round(double.Parse(string.IsNullOrEmpty(this.hfLatitude.Value) ? "0" : this.hfLatitude.Value), 6);
                if (this.ValidationShipper(shippersInfo))
                {
                    if (string.IsNullOrEmpty(shippersInfo.CellPhone) && string.IsNullOrEmpty(shippersInfo.TelPhone))
                    {
                        this.ShowMsg("手机号码和电话号码必填其一", false);
                    }
                    else
                    {
                        long num = SalesHelper.AddShipperRetrunID(shippersInfo);
                        if (num > 0)
                        {
                            try
                            {
                                SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                                string       phone          = (!string.IsNullOrEmpty(shippersInfo.CellPhone)) ? shippersInfo.CellPhone : shippersInfo.TelPhone;
                                string       text           = "0";
                                double       lng            = shippersInfo.Longitude.ToDouble(0);
                                double       lat            = shippersInfo.Latitude.ToDouble(0);
                                string[]     array          = this.ddlReggion.SelectedRegions.Split(',');
                                string       city_name      = array[1].Replace("市", "");
                                string       area_name      = array[2];
                                string       str            = array[3];
                                string       text2          = DadaHelper.shopAddOrUpdate(masterSettings.DadaSourceID, masterSettings.SiteName, 5, city_name, area_name, str + " " + shippersInfo.Address, lng, lat, shippersInfo.ShipperName, phone, "P_" + num, 1);
                            }
                            catch (Exception)
                            {
                                this.ShowMsg("添加达达物流信息失败", false);
                            }
                            this.ShowMsg("成功添加了一个发货信息", true, "Shippers.aspx");
                        }
                        else
                        {
                            this.ShowMsg("添加发货信息失败", false);
                        }
                    }
                }
            }
        }