Exemple #1
0
        /// <summary>
        /// get lxrs
        /// </summary>
        /// <returns></returns>
        IList <EyouSoft.Model.CrmStructure.MCrmLinkman> GetLxrs()
        {
            IList <EyouSoft.Model.CrmStructure.MCrmLinkman> items = new List <EyouSoft.Model.CrmStructure.MCrmLinkman>();

            string[] BirthdayArray    = Utils.GetFormValues("txtlBirthday");
            string[] DepartmentArray  = Utils.GetFormValues("txtlDepartment");
            string[] FaxArray         = Utils.GetFormValues("txtlFax");
            string[] MobilePhoneArray = Utils.GetFormValues("txtlMobilePhone");
            string[] NameArray        = Utils.GetFormValues("txtllinkManName");
            string[] QQArray          = Utils.GetFormValues("txtlQQ");
            string[] TelephoneArray   = Utils.GetFormValues("txtlTel");
            string[] AddressArray     = Utils.GetFormValues("txtlAddress");
            string[] IsRemindArray    = Utils.GetFormValues("txtIsTiXing");
            string[] LinkManId        = Utils.GetFormValues("hidlLinkManId");

            if (DepartmentArray == null || DepartmentArray.Length == 0)
            {
                return(null);
            }

            for (int i = 0; i < DepartmentArray.Length; i++)
            {
                if (string.IsNullOrEmpty(DepartmentArray[i]))
                {
                    continue;
                }

                var item = new EyouSoft.Model.CrmStructure.MCrmLinkman();
                item.Id          = LinkManId[i];
                item.Birthday    = Utils.GetDateTimeNullable(BirthdayArray[i]);
                item.CompanyId   = CurrentUserCompanyID;
                item.Department  = DepartmentArray[i];
                item.Fax         = FaxArray[i];
                item.MobilePhone = MobilePhoneArray[i];
                item.Name        = NameArray[i];
                item.QQ          = QQArray[i];
                item.Telephone   = TelephoneArray[i];
                item.Type        = EyouSoft.Model.EnumType.ComStructure.LxrType.客户单位;
                item.IsRemind    = IsRemindArray[i] == "1";
                item.Address     = AddressArray[i];

                items.Add(item);
            }

            return(items);
        }
Exemple #2
0
        /// <summary>
        /// get crm lxr
        /// </summary>
        /// <param name="crmId">crmid</param>
        /// <returns></returns>
        IList <EyouSoft.Model.CrmStructure.MCrmLinkman> GetCrmLxrs(string crmId)
        {
            IList <EyouSoft.Model.CrmStructure.MCrmLinkman> items = new List <EyouSoft.Model.CrmStructure.MCrmLinkman>();
            DbCommand cmd = _db.GetSqlStringCommand(SQL_SELECT_GetCrmLxrs);

            _db.AddInParameter(cmd, "CrmId", DbType.AnsiStringFixedLength, crmId);
            _db.AddInParameter(cmd, "LxrType", DbType.Byte, EyouSoft.Model.EnumType.ComStructure.LxrType.客户单位);

            using (IDataReader rdr = DbHelper.ExecuteReader(cmd, _db))
            {
                while (rdr.Read())
                {
                    var item = new EyouSoft.Model.CrmStructure.MCrmLinkman();

                    item.Address = rdr["Address"].ToString();
                    if (!rdr.IsDBNull(rdr.GetOrdinal("Birthday")))
                    {
                        item.Birthday = rdr.GetDateTime(rdr.GetOrdinal("Birthday"));
                    }
                    item.CompanyId   = rdr.GetString(rdr.GetOrdinal("CompanyId"));
                    item.Department  = rdr["Department"].ToString();
                    item.Fax         = rdr["Fax"].ToString();
                    item.Id          = rdr.GetString(rdr.GetOrdinal("Id"));
                    item.IsRemind    = rdr.GetString(rdr.GetOrdinal("IsRemind")) == "1";
                    item.IssueTime   = rdr.GetDateTime(rdr.GetOrdinal("IssueTime"));
                    item.MobilePhone = rdr["MobilePhone"].ToString();
                    item.Name        = rdr["Name"].ToString();
                    item.QQ          = rdr["QQ"].ToString();
                    item.Telephone   = rdr["Telephone"].ToString();
                    item.Type        = EyouSoft.Model.EnumType.ComStructure.LxrType.客户单位;
                    item.TypeId      = crmId;
                    item.UserId      = rdr["UserId"].ToString().Trim();

                    items.Add(item);
                }
            }

            return(items);
        }
Exemple #3
0
        /// <summary>
        /// 获得联系人列表
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <param name="TypeId">类型编号</param>
        /// <param name="Type">类型</param>
        /// <returns></returns>
        public IList <Model.CrmStructure.MCrmLinkman> GetLinkManModelList(string companyId, string TypeId, int Type)
        {
            IList <Model.CrmStructure.MCrmLinkman> list = new List <Model.CrmStructure.MCrmLinkman>();
            DbCommand dc = _db.GetSqlStringCommand(sql_Crm_SelectLinkman);

            _db.AddInParameter(dc, "CompanyId", DbType.AnsiStringFixedLength, companyId);
            _db.AddInParameter(dc, "TypeId", DbType.AnsiStringFixedLength, TypeId);
            _db.AddInParameter(dc, "Type", DbType.Byte, Type);
            using (IDataReader reader = DbHelper.ExecuteReader(dc, _db))
            {
                while (reader.Read())
                {
                    EyouSoft.Model.CrmStructure.MCrmLinkman linkmanModel = new EyouSoft.Model.CrmStructure.MCrmLinkman();
                    linkmanModel.Birthday    = reader.IsDBNull(reader.GetOrdinal("Birthday")) ? null : (DateTime?)(reader["Birthday"]);
                    linkmanModel.CompanyId   = !reader.IsDBNull(reader.GetOrdinal("CompanyId")) ? (string)reader["CompanyId"] : string.Empty;
                    linkmanModel.Department  = !reader.IsDBNull(reader.GetOrdinal("Department")) ? (string)reader["Department"] : string.Empty;
                    linkmanModel.EMail       = !reader.IsDBNull(reader.GetOrdinal("EMail")) ? (string)reader["EMail"] : string.Empty;
                    linkmanModel.Fax         = !reader.IsDBNull(reader.GetOrdinal("Fax")) ? (string)reader["Fax"] : string.Empty;
                    linkmanModel.Gender      = (EyouSoft.Model.EnumType.GovStructure.Gender)(int.Parse(reader["Gender"].ToString()));
                    linkmanModel.Id          = !reader.IsDBNull(reader.GetOrdinal("Id")) ? (string)reader["Id"] : string.Empty;
                    linkmanModel.MobilePhone = !reader.IsDBNull(reader.GetOrdinal("MobilePhone")) ? (string)reader["MobilePhone"] : string.Empty;
                    linkmanModel.Name        = !reader.IsDBNull(reader.GetOrdinal("Name")) ? (string)reader["Name"] : string.Empty;
                    linkmanModel.Post        = !reader.IsDBNull(reader.GetOrdinal("Post")) ? (string)reader["Post"] : string.Empty;
                    linkmanModel.QQ          = !reader.IsDBNull(reader.GetOrdinal("QQ")) ? (string)reader["QQ"] : string.Empty;
                    linkmanModel.Telephone   = !reader.IsDBNull(reader.GetOrdinal("Telephone")) ? (string)reader["Telephone"] : string.Empty;
                    linkmanModel.Type        = (EyouSoft.Model.EnumType.ComStructure.LxrType)(int.Parse(reader["Type"].ToString()));
                    linkmanModel.TypeId      = !reader.IsDBNull(reader.GetOrdinal("TypeId")) ? (string)reader["TypeId"] : string.Empty;
                    linkmanModel.UserId      = !reader.IsDBNull(reader.GetOrdinal("UserId")) ? (string)reader["UserId"] : string.Empty;
                    linkmanModel.Address     = !reader.IsDBNull(reader.GetOrdinal("Address")) ? (string)reader["Address"] : string.Empty;
                    linkmanModel.IsRemind    = !reader.IsDBNull(reader.GetOrdinal("IsRemind")) ? reader["IsRemind"].ToString() == "0" ? false : true : false;
                    linkmanModel.SortId      = (int)reader["SortId"];
                    linkmanModel.IssueTime   = (DateTime)reader["IssueTime"];
                    list.Add(linkmanModel);
                }
            }
            return(list);
        }
        /// <summary>
        /// 页面验证
        /// </summary>
        /// <param name="order"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool PageValidate(ref EyouSoft.Model.TourStructure.MTourOrderExpand order, ref string msg)
        {
            //验证的字段
            string DCompanyName = Utils.GetFormValue("txtDCompanyName");

            if (string.IsNullOrEmpty(DCompanyName))
            {
                msg += "客源单位 不能为空!</br>";
            }
            string DContactName = Utils.GetFormValue("txtDContactName");

            if (string.IsNullOrEmpty(DContactName))
            {
                msg += "联系人 不能为空!</br>";
            }

            string DContactTel = Utils.GetFormValue("txtDContactTel");

            if (string.IsNullOrEmpty(DContactTel))
            {
                msg += "联系定电话 不能为空!</br>";
            }

            int Adults = Utils.GetInt(Utils.GetFormValue("txtAdults"));

            if (Adults < 0)
            {
                msg += "成人数 格式不正确!</br>";
            }

            int Childs = Utils.GetInt(Utils.GetFormValue("txtChilds"));

            if (Childs < 0)
            {
                msg += "儿童数 格式不正确!</br>";
            }
            decimal SumPrice = Utils.GetDecimal(Utils.GetFormValue("txtSumPrice"));

            if (SumPrice <= 0)
            {
                msg += "合计金额 格式不正确!</br>";
            }
            string saveDate = Utils.GetFormValue("txtSaveSeatDate");

            if (!string.IsNullOrEmpty(saveDate))
            {
                DateTime?SaveSeatDate = Utils.GetDateTimeNullable(saveDate);
                if (!SaveSeatDate.HasValue)
                {
                    msg += "留位时间 格式不正确!</br>";
                }
            }
            string tourType = Utils.GetFormValue("hfTourType");

            if (msg.Length <= 0)
            {
                //短线
                if (!string.IsNullOrEmpty(Utils.GetQueryStringValue("IsShort")))
                {
                    string CarLocationID = Utils.GetFormValue("selPickUpPosition");
                    if (!string.IsNullOrEmpty(CarLocationID))
                    {
                        EyouSoft.Model.TourStructure.MTourOrderCarLocation modelcar = new EyouSoft.Model.TourStructure.MTourOrderCarLocation();
                        string location = this.hidlocation.Value;
                        string desc     = this.hidDesc.Value;
                        modelcar.Desc              = desc;
                        modelcar.Location          = location;
                        modelcar.OffPrice          = Utils.GetDecimal(this.hidOffPrice.Value);
                        modelcar.OnPrice           = Utils.GetDecimal(this.hidOnPrice.Value);
                        modelcar.TourLocationId    = CarLocationID;
                        order.TourOrderCarLocation = modelcar;
                    }
                    IList <EyouSoft.Model.TourStructure.MTourOrderCarTypeSeat> listSeat = new List <EyouSoft.Model.TourStructure.MTourOrderCarTypeSeat>();
                    listSeat = Newtonsoft.Json.JsonConvert.DeserializeObject <IList <MTourOrderCarTypeSeat> >(Utils.GetFormValue(this.SetSeat1.setSeatHidClientID));
                    order.TourOrderCarTypeSeatList = listSeat;
                }
                order.CompanyId      = SiteUserInfo.CompanyId;
                order.TourId         = Utils.GetQueryStringValue("TourId");
                order.BuyCompanyName = SiteUserInfo.TourCompanyInfo.CompanyName;
                order.BuyCompanyId   = SiteUserInfo.TourCompanyInfo.CompanyId;
                //客源单位联系人信息(当前分销商)
                string lxrId = SiteUserInfo.TourCompanyInfo.LxrId;
                order.ContactDepartId = lxrId;
                EyouSoft.BLL.CrmStructure.BCrmLinkMan   link    = new EyouSoft.BLL.CrmStructure.BCrmLinkMan();
                EyouSoft.Model.CrmStructure.MCrmLinkman linkMan = link.GetLinkManModel(lxrId);
                if (linkMan != null)
                {
                    order.ContactName = linkMan.Name;
                    order.ContactTel  = linkMan.Telephone;
                }


                order.OrderStatus = EyouSoft.Model.EnumType.TourStructure.OrderStatus.未处理;

                //联系人信息
                order.DCompanyName = DCompanyName;
                order.DContactName = DContactName;
                order.DContactTel  = DContactTel;



                //销售员信息
                order.SellerId   = SiteUserInfo.UserId;
                order.SellerName = SiteUserInfo.Name;
                order.DeptId     = SiteUserInfo.DeptId;

                //操作员信息
                order.Operator   = SiteUserInfo.Name;
                order.OperatorId = SiteUserInfo.UserId;

                order.Adults = Adults;
                order.Childs = Childs;

                //价格组成
                string strPrice = Utils.GetFormValue("txt_PriceStand_radio_price");
                if (!string.IsNullOrEmpty(strPrice))
                {
                    string[] price = strPrice.Split('|');
                    order.LevId      = Utils.GetInt(price[0]);
                    order.AdultPrice = Utils.GetDecimal(price[1]);
                    order.ChildPrice = Utils.GetDecimal(price[2]);
                }

                string strStandard = Utils.GetFormValue("_hstandard");
                if (!string.IsNullOrEmpty(strStandard))
                {
                    int Standard = Utils.GetInt(strStandard);
                    order.PriceStandId = Standard;
                    EyouSoft.BLL.TourStructure.BTour                        bll          = new EyouSoft.BLL.TourStructure.BTour();
                    EyouSoft.Model.TourStructure.MTourSanPinInfo            model        = (EyouSoft.Model.TourStructure.MTourSanPinInfo)bll.GetTourInfo(order.TourId);
                    IList <EyouSoft.Model.TourStructure.MTourPriceStandard> standardList = model.MTourPriceStandard.Where(c => c.Standard == Standard).ToList();

                    if (standardList != null && standardList.Count != 0)
                    {
                        List <EyouSoft.Model.TourStructure.MTourPriceLevel> levelList = new List <EyouSoft.Model.TourStructure.MTourPriceLevel>();
                        foreach (var a in standardList)
                        {
                            levelList.AddRange(a.PriceLevel);
                        }
                        if (levelList != null && levelList.Count != 0)
                        {
                            EyouSoft.Model.TourStructure.MTourPriceLevel item = levelList.SingleOrDefault(c => c.LevType == EyouSoft.Model.EnumType.ComStructure.LevType.内部结算价);
                            if (item != null)
                            {
                                order.PeerAdultPrice  = item.AdultPrice;
                                order.PeerChildPrice  = item.ChildPrice;
                                order.PeerLevId       = item.LevelId;
                                order.SettlementMoney = order.PeerAdultPrice * Adults + order.PeerChildPrice * Childs;
                            }
                        }
                    }
                }

                order.SaleAddCost          = Utils.GetDecimal(Utils.GetFormValue("txtSaleAddCost"));
                order.SaleAddCostRemark    = Utils.GetFormValue("txtSaleAddCostRemark");
                order.SaleReduceCost       = Utils.GetDecimal(Utils.GetFormValue("txtSaleReduceCost"));
                order.SaleReduceCostRemark = Utils.GetFormValue("txtSaleReduceCostRemark");

                order.SumPrice = Utils.GetDecimal(Utils.GetFormValue("txtSumPrice"));

                order.SaveSeatDate = Utils.GetDateTimeNullable(Utils.GetFormValue("txtSaveSeatDate"));
                order.OrderRemark  = Utils.GetFormValue("txtOrderRemark");



                order.OrderType = EyouSoft.Model.EnumType.TourStructure.OrderType.分销商下单;

                order.MTourOrderTravellerList = new List <EyouSoft.Model.TourStructure.MTourOrderTraveller>();
                order.TourType = (EyouSoft.Model.EnumType.TourStructure.TourType)Enum.Parse(typeof(EyouSoft.Model.EnumType.TourStructure.TourType), tourType);
                switch (order.TourType)
                {
                case EyouSoft.Model.EnumType.TourStructure.TourType.组团散拼:
                case TourType.组团散拼短线:
                case EyouSoft.Model.EnumType.TourStructure.TourType.地接散拼:
                    order.MTourOrderTravellerList = UtilsCommons.GetTravelList();
                    break;

                case EyouSoft.Model.EnumType.TourStructure.TourType.出境散拼:
                    order.MTourOrderTravellerList = UtilsCommons.GetTravelListS();
                    break;
                }
            }

            return(msg.Length <= 0);
        }
Exemple #5
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        private string PageSave(string doType, string id)
        {
            string msg = string.Empty;
            //t为false为编辑,true时为新增
            bool t = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true;

            //国家
            #region 表单取值
            string country = Utils.GetFormValue(this.ddlCountry.UniqueID);
            //省份
            string provice = Utils.GetFormValue(this.ddlProvice.UniqueID);
            //城市
            string city = Utils.GetFormValue(this.ddlCity.UniqueID);
            //县区
            string area = Utils.GetFormValue(this.ddlArea.UniqueID);
            //地址
            string address = Utils.GetFormValue(this.txtaddress.UniqueID);
            //单位名称
            string UnitName = Utils.GetFormValue(this.txtUnitName.UniqueID);
            //线路特色
            string Character = Utils.GetFormValue(this.txtCharacter.UniqueID);
            //合同开始时间
            string ContractStartDate = Utils.GetFormValue(this.txtContractDate_Start.UniqueID);
            //合同有到期时间
            string ContractDate = Utils.GetFormValue(this.txtContractDate.UniqueID);
            //合同号
            string ContractNum = Utils.GetFormValue(this.txtContractNum.UniqueID);
            //法人代表
            string LegalName = Utils.GetFormValue(this.txtLegalName.UniqueID);
            //许可证号
            string PermitNum = Utils.GetFormValue(this.txtPermitNum.UniqueID);
            //返佣政策
            string Policy = Utils.GetFormValue(this.txtpolicy.UniqueID);
            //联系电话
            string Tel = Utils.GetFormValue(this.txtTel.UniqueID);
            //合同附件(新)
            string[] visaUpload    = Utils.GetFormValues(this.UploadControl1.ClientHideID);
            string[] oldVisaUpload = Utils.GetFormValues("hideFileInfo");
            #endregion

            EyouSoft.Model.CrmStructure.MCrmLinkman m = new EyouSoft.Model.CrmStructure.MCrmLinkman();
            MComUser mUser = new MComUser();
            IList <EyouSoft.Model.CrmStructure.MCrmLinkman> list = UtilsCommons.GetDataList();
            if (list != null && list.Count > 0)
            {
                mUser.ContactMobile = list[0].MobilePhone;
                mUser.ContactName   = list[0].Name;
                mUser.ContactTel    = list[0].Telephone;
                mUser.QQ            = list[0].QQ;
                m.Post = list[0].Post;
            }
            if (string.IsNullOrEmpty(UnitName))
            {
                msg = "{\"result\":\"0\",\"msg\":\"单位名称不能为空!\"}";
                return(msg);
            }
            EyouSoft.Model.SourceStructure.MSourceTravel mTravel = new EyouSoft.Model.SourceStructure.MSourceTravel();
            if (!string.IsNullOrEmpty(id))
            {
                mTravel = new EyouSoft.BLL.SourceStructure.BSource().GetTravelServiceModel(id);
            }
            EyouSoft.Model.SourceStructure.MSource mModel = new EyouSoft.Model.SourceStructure.MSource();
            mModel.Address      = this.txtaddress.Text;
            mModel.CityId       = Utils.GetInt(Utils.GetFormValue(this.ddlCity.UniqueID));
            mModel.CountryId    = Utils.GetInt(Utils.GetFormValue(this.ddlCountry.UniqueID));
            mModel.CountyId     = Utils.GetInt(Utils.GetFormValue(this.ddlArea.UniqueID));
            mModel.ProvinceId   = Utils.GetInt(Utils.GetFormValue(this.ddlProvice.UniqueID));
            mModel.Name         = Utils.GetFormValue(this.txtUnitName.UniqueID).Trim();
            mModel.CompanyId    = this.SiteUserInfo.CompanyId;
            mModel.OperatorId   = this.SiteUserInfo.UserId;
            mModel.ContractCode = ContractNum;
            mModel.DeptId       = this.SiteUserInfo.DeptId;

            mModel.ContractPeriodStart = String.IsNullOrEmpty(ContractStartDate) ? null : (DateTime?)DateTime.Parse(ContractStartDate);
            mModel.ContractPeriodEnd   = String.IsNullOrEmpty(ContractDate) ? null : (DateTime?)DateTime.Parse(ContractDate);

            //签单
            if (RadSign_no.Checked)
            {
                mModel.IsPermission = false;
            }
            else
            {
                mModel.IsPermission = true;
            }
            //推荐
            if (RadRecommend_no.Checked)
            {
                mModel.IsRecommend = false;
            }
            else
            {
                mModel.IsRecommend = true;
            }
            //返佣
            mModel.IsCommission = true;
            if (radno.Checked)
            {
                mModel.IsCommission = false;
            }
            //合同
            if (Radio_hd_no.Checked)
            {
                mModel.IsSignContract = false;
            }
            else
            {
                mModel.IsSignContract = true;
                mModel.ContractCode   = Utils.GetFormValue(this.txtContractNum.UniqueID);
            }
            mModel.LastModifierId = this.SiteUserInfo.Name;
            mModel.LastModifyTime = DateTime.Now;
            mModel.LicenseKey     = PermitNum;
            mModel.UnitPolicy     = Policy;
            mModel.Desc           = Character;
            mModel.IssueTime      = DateTime.Now;

            if (!String.IsNullOrEmpty(id))
            {
                mModel.SourceId = id;
            }

            #region 合同附件
            EyouSoft.Model.ComStructure.MComAttach visaModel = new EyouSoft.Model.ComStructure.MComAttach();
            if (oldVisaUpload.Length > 0)
            {
                for (int i = 0; i < oldVisaUpload.Length; i++)
                {
                    visaModel.FilePath = oldVisaUpload[i].Split('|')[1];
                    visaModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商合同附件;
                    visaModel.Name     = oldVisaUpload[i].Split('|')[0];
                    visaModel.Size     = 0;
                }
            }
            if (visaUpload.Length > 0)
            {
                for (int i = 0; i < visaUpload.Length; i++)
                {
                    if (visaUpload[i].Trim() != "")
                    {
                        if (visaUpload[i].Split('|').Length > 1)
                        {
                            visaModel.Downloads = 0;
                            visaModel.FilePath  = visaUpload[i].Split('|')[1];
                            visaModel.ItemType  = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商合同附件;
                            visaModel.Name      = visaUpload[i].Split('|')[0];
                            visaModel.Size      = 0;
                        }
                    }
                }
            }

            mModel.ContractAttach = visaModel;
            #endregion

            mUser.CompanyId = this.SiteUserInfo.CompanyId;
            //mUser.IsEnable = true;
            mUser.IssueTime = DateTime.Now;
            mUser.UserType  = EyouSoft.Model.EnumType.ComStructure.UserType.供应商;
            MSourceTravelInfo Traveinfo = new MSourceTravelInfo();
            Traveinfo.LegalRepresentative = LegalName;
            Traveinfo.Routes          = Character;
            Traveinfo.Telephone       = Tel;
            mTravel.SourceTravelModel = Traveinfo;
            //mTravel.UserModel = mUser;
            mTravel.SourceModel = mModel;
            mTravel.LinkManList = list;
            //mTravel.SourceTravelModel
            EyouSoft.BLL.SourceStructure.BSource bllsource = new EyouSoft.BLL.SourceStructure.BSource();
            EyouSoft.BLL.ComStructure.BComUser   blluser   = new EyouSoft.BLL.ComStructure.BComUser();

            int result = 0;
            if (t)
            {//新增
                result = bllsource.AddTravelServiceModel(mTravel);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"单位名称已存在!\"}";
                    return(msg);
                }
            }
            else
            { //编辑
                result = bllsource.UpdateTravelServiceModel(mTravel);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"单位名称已存在!\"}";
                    return(msg);
                }
            }
            string type = t ? "新增" : "修改";
            if (result > 0)
            {
                msg = "{\"result\":\"1\",\"msg\":\"" + type + "成功!\"}";
                return(msg);
            }
            else
            {
                msg = "{\"result\":\"0\",\"msg\":\"" + type + "失败!\"}";
                return(msg);
            }
        }
Exemple #6
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected string PageSave()
        {
            EyouSoft.Model.CrmStructure.MCrm crmModel = new EyouSoft.Model.CrmStructure.MCrm();
            if (!string.IsNullOrEmpty(Utils.GetQueryStringValue("crmId")))
            {
                crmModel = crmBll.GetInfo(EyouSoft.Common.Utils.GetQueryStringValue("crmId"));
            }
            #region 客户主体信息
            //获取form参数
            int    Country          = Utils.GetInt(Utils.GetFormValue(ddlCountry.UniqueID), 0);           //国家
            int    Provice          = Utils.GetInt(Utils.GetFormValue(ddlProvice.UniqueID), 0);           //省份
            int    City             = Utils.GetInt(Utils.GetFormValue(ddlCity.UniqueID), 0);              //城市
            int    County           = Utils.GetInt(Utils.GetFormValue(ddlCounty.UniqueID), 0);            //县区
            int    Type             = (int)EyouSoft.Model.EnumType.CrmStructure.CrmType.行客户;              //客户类型
            string Name             = Utils.GetFormValue(txtName.UniqueID);                               //单位名称
            string Address          = Utils.GetFormValue(txtAddress.UniqueID);                            //地址
            string OrganizationCode = Utils.GetFormValue(txtOrganizationCode.UniqueID);                   //机构代码
            //string VouchersCode = Utils.GetFormValue("txtVouchersCode");//凭证代码
            int    LevId                     = Utils.GetInt(Utils.GetFormValue(ddlLevId.UniqueID), 0);    //客户等级
            string License                   = Utils.GetFormValue(txtLicense.UniqueID);                   //许可证号
            string LegalRepresentative       = Utils.GetFormValue(txtLegalRepresentative.UniqueID);       //法人代表
            string LegalRepresentativePhone  = Utils.GetFormValue(txtLegalRepresentativePhone.UniqueID);  //法人代表电话
            string LegalRepresentativeMobile = Utils.GetFormValue(txtLegalRepresentativeMobile.UniqueID); //法人代表手机
            string FinancialName             = Utils.GetFormValue(txtFinancialName.UniqueID);             //财务姓名
            string FinancialPhone            = Utils.GetFormValue(txtFinancialPhone.UniqueID);            //财务电话
            string FinancialMobile           = Utils.GetFormValue(txtFinancialMobile.UniqueID);           //财务手机

            //decimal PreDeposits =Utils.GetDecimal(Utils.GetFormValue("txtPreDeposits"));//预存款
            string RebatePolicy = Utils.GetFormValue(txtRebatePolicy.UniqueID); //返利政策
            string BrevityCode  = Utils.GetFormValue(txtBrevityCode.UniqueID);  //简码
            //string UserAccount = Utils.GetFormValue("txtUserAccount");//分销账号

            crmModel.Address = Address;

            crmModel.CityId    = City;
            crmModel.CompanyId = base.SiteUserInfo.CompanyId;

            crmModel.IssueTime                = DateTime.Now;
            crmModel.LegalRepresentative      = LegalRepresentative;
            crmModel.LegalRepresentativePhone = LegalRepresentativePhone;
            crmModel.LevId            = LevId;
            crmModel.License          = License;
            crmModel.Name             = Name;
            crmModel.OperatorId       = base.SiteUserInfo.UserId;
            crmModel.OrganizationCode = OrganizationCode;
            crmModel.ProvinceId       = Provice;
            crmModel.RebatePolicy     = RebatePolicy;
            if (this.CheckGrant(EyouSoft.Model.EnumType.PrivsStructure.Privs.客户管理_单位直客_修改责任销售))
            {
                crmModel.SellerId = Utils.GetFormValue(Seller1.SellsIDClient);
            }
            crmModel.Type                      = (EyouSoft.Model.EnumType.CrmStructure.CrmType)(Type);
            crmModel.BrevityCode               = BrevityCode;
            crmModel.CountryId                 = Country;
            crmModel.CountyId                  = County;
            crmModel.DeptId                    = base.SiteUserInfo.DeptId;
            crmModel.FinancialMobile           = FinancialMobile;
            crmModel.FinancialName             = FinancialName;
            crmModel.FinancialPhone            = FinancialPhone;
            crmModel.LegalRepresentativeMobile = LegalRepresentativeMobile;

            #endregion

            #region 常用联系人
            IList <EyouSoft.Model.CrmStructure.MCrmLinkman> linkManList = new List <EyouSoft.Model.CrmStructure.MCrmLinkman>();
            string[] BirthdayArray    = Utils.GetFormValues("txtlBirthday");
            string[] DepartmentArray  = Utils.GetFormValues("txtlDepartment");
            string[] FaxArray         = Utils.GetFormValues("txtlFax");
            string[] MobilePhoneArray = Utils.GetFormValues("txtlMobilePhone");
            string[] NameArray        = Utils.GetFormValues("txtllinkManName");
            string[] QQArray          = Utils.GetFormValues("txtlQQ");
            string[] TelephoneArray   = Utils.GetFormValues("txtlTel");
            string[] AddressArray     = Utils.GetFormValues("txtlAddress");
            string[] IsRemindArray    = Utils.GetFormValues("hidIsRemind");
            string[] LinkManId        = Utils.GetFormValues("hidlLinkManId");
            string[] UserId           = Utils.GetFormValues("hidlUserId");
            for (int j = 0; j < DepartmentArray.Length; j++)
            {
                EyouSoft.Model.CrmStructure.MCrmLinkman model = new EyouSoft.Model.CrmStructure.MCrmLinkman();
                if (LinkManId.Length == 0)
                {
                    model.Id = string.Empty;
                }
                model.Id = LinkManId[j] == string.Empty ? string.Empty : LinkManId[j];
                if (UserId.Length == 0)
                {
                    model.UserId = string.Empty;
                }
                else
                {
                    model.UserId = UserId[j] == string.Empty ? string.Empty : UserId[j];
                }
                model.Birthday    = !string.IsNullOrEmpty(BirthdayArray[j]) ? (DateTime?)(DateTime.Parse(BirthdayArray[j])) : null;
                model.CompanyId   = base.SiteUserInfo.CompanyId;
                model.Department  = !string.IsNullOrEmpty(DepartmentArray[j]) ? DepartmentArray[j] : string.Empty;
                model.Fax         = !string.IsNullOrEmpty(FaxArray[j]) ? FaxArray[j] : string.Empty;
                model.MobilePhone = !string.IsNullOrEmpty(MobilePhoneArray[j]) ? MobilePhoneArray[j] : string.Empty;
                model.Name        = !string.IsNullOrEmpty(NameArray[j]) ? NameArray[j] : string.Empty;
                model.QQ          = !string.IsNullOrEmpty(QQArray[j]) ? QQArray[j] : string.Empty;
                model.Telephone   = !string.IsNullOrEmpty(TelephoneArray[j]) ? TelephoneArray[j] : string.Empty;
                model.Type        = (EyouSoft.Model.EnumType.ComStructure.LxrType)(Type);
                if (IsRemindArray.Length == 0)
                {
                    model.IsRemind = false;
                }
                else
                {
                    model.IsRemind = IsRemindArray[j] == string.Empty ? false : true;
                }
                model.Address = !string.IsNullOrEmpty(AddressArray[j]) ? AddressArray[j] : string.Empty;
                if (string.IsNullOrEmpty(model.Birthday.ToString()) && string.IsNullOrEmpty(model.Department) && string.IsNullOrEmpty(model.Fax) && string.IsNullOrEmpty(model.MobilePhone) && string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.QQ) && string.IsNullOrEmpty(model.Telephone) && string.IsNullOrEmpty(model.Address))
                {
                }
                else
                {
                    linkManList.Add(model);
                }
            }
            crmModel.LinkManList = linkManList != null || linkManList.Count != 0 ? linkManList : null;
            #endregion
            string filepath = string.Empty;
            string filename = string.Empty;
            #region 结算账户
            if (this.CheckGrant(EyouSoft.Model.EnumType.PrivsStructure.Privs.客户管理_单位直客_常用设置))
            {
                decimal AmountOwed = Utils.GetDecimal(Utils.GetFormValue("txtAmountOwed")); //欠款额度
                int     Deadline   = Utils.GetInt(Utils.GetFormValue("txtDeadline"));       //单团账龄期限
                crmModel.AmountOwed = AmountOwed;
                crmModel.Deadline   = Deadline;
                IList <EyouSoft.Model.CrmStructure.MCrmBank> bankList = new List <EyouSoft.Model.CrmStructure.MCrmBank>();
                string[] BankAccountArray = Utils.GetFormValues("txtBankAccount");
                string[] BankNameArray    = Utils.GetFormValues("txtBankName");
                string[] BankId           = Utils.GetFormValues("hidBankId");
                for (int j = 0; j < BankNameArray.Length; j++)
                {
                    EyouSoft.Model.CrmStructure.MCrmBank model = new EyouSoft.Model.CrmStructure.MCrmBank();
                    model.BankAccount = !string.IsNullOrEmpty(BankAccountArray[j]) ? BankAccountArray[j] : string.Empty;
                    model.BankName    = !string.IsNullOrEmpty(BankNameArray[j]) ? BankNameArray[j] : string.Empty;
                    model.BankId      = BankId[j] == string.Empty ? string.Empty : BankId[j];
                    if (string.IsNullOrEmpty(model.BankAccount) && string.IsNullOrEmpty(model.BankName))
                    {
                    }
                    else
                    {
                        bankList.Add(model);
                    }
                }

                if (rbtnIsSignContractYes.Checked)
                {
                    crmModel.IsSignContract = true;
                }
                else if (rbtnIsSignContractNo.Checked)
                {
                    crmModel.IsSignContract = false;
                }


                string[] path = Utils.GetFormValue(this.UploadControl1.ClientHideID).Split('|');
                if (path.Length > 1)
                {
                    filename = path[0];
                    filepath = path[1];
                    EyouSoft.Model.ComStructure.MComAttach attachModel = new EyouSoft.Model.ComStructure.MComAttach();
                    attachModel.Downloads = 0;
                    attachModel.FilePath  = filepath;
                    attachModel.Name      = System.IO.Path.GetFileName(filepath);
                    crmModel.AttachModel  = attachModel;
                }
                crmModel.BankList = bankList != null || bankList.Count != 0 ? bankList : null;
            }

            #endregion

            bool isAdd = Utils.GetQueryStringValue("isadd") == "false" ? false : true;
            #region 数据操作
            if (!string.IsNullOrEmpty(Utils.GetQueryStringValue("crmId")))
            {
                crmModel.CrmId = Utils.GetQueryStringValue("crmId");;

                int result = 0;//crmBll.UpdateUnitCustomerModel(crmModel, isAdd);

                switch (result)
                {
                case -1:
                    return(UtilsCommons.AjaxReturnJson("-1", "已经存在相同的银行卡号!"));

                case -4:
                    return(UtilsCommons.AjaxReturnJson("-4", "客户编号未赋值!"));

                case -2:
                    return(UtilsCommons.AjaxReturnJson("-2", "已经存在相同的分销商帐号!"));

                case -3:
                    return(UtilsCommons.AjaxReturnJson("-3", "客户必填信息不完善!"));

                case 0:
                    return(UtilsCommons.AjaxReturnJson("0", "事务回滚!"));

                case 1:
                    return(UtilsCommons.AjaxReturnJson("1", "修改成功!"));

                case -5:
                    return(UtilsCommons.AjaxReturnJson("-5", "已经存在相同的单位名称"));

                default:
                    return(UtilsCommons.AjaxReturnJson("-7", "数据操作失败!"));
                }
            }
            else
            {
                int result = 0; //crmBll.AddUnitCustomerModel(crmModel, isAdd);

                switch (result)
                {
                case -1:
                    return(UtilsCommons.AjaxReturnJson("-1", "已经存在相同的银行卡号!"));

                case -4:
                    return(UtilsCommons.AjaxReturnJson("-4", "公司编号未赋值!"));

                case -2:
                    return(UtilsCommons.AjaxReturnJson("-2", "已经存在相同的分销商帐号!"));

                case -3:
                    return(UtilsCommons.AjaxReturnJson("-3", "客户必填信息不完善!"));

                case 0:
                    return(UtilsCommons.AjaxReturnJson("0", "事务回滚!"));

                case 1:
                    return(UtilsCommons.AjaxReturnJson("1", "添加成功!"));

                case -5:
                    return(UtilsCommons.AjaxReturnJson("-5", "已经存在相同的单位名称"));

                default:
                    return(UtilsCommons.AjaxReturnJson("-7", "数据操作失败!"));
                }
            }
            #endregion
        }