Ejemplo n.º 1
0
        public void ApprovePendingCustomer(CRMCustomer entity)
        {
            if (this.dataCtx.Connection != null)
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                    this.dataCtx.Connection.Open();
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();
            dataCtx.Transaction = tran;

            try
            {
                var qry = from t in CRMCustomers
                          where t.CustID == entity.CustID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    obj.Status = "A";

                }

                //����ͻ���Ϣ,�õ����µ�entity.CustID
                this.dataCtx.SubmitChanges();
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Ejemplo n.º 2
0
        public void RejectPendingCustomer(CRMCustomer entity)
        {
            if (this.dataCtx.Connection != null)
            {
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                {
                    this.dataCtx.Connection.Open();
                }
            }
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();

            dataCtx.Transaction = tran;

            try
            {
                long MaxVersion = CRMCustomerHistorys.Where(t => t.CustID == entity.CustID).Max(t => t.Version);
                var  qry        = from t in CRMCustomerHistorys
                                  where t.CustID == entity.CustID && t.Version == MaxVersion
                                  select t;
                var OldCust = qry.SingleOrDefault();
                if (OldCust != null)
                {
                    //把历史表旧记录copy到Customer表
                    this.CopyEntity(entity, OldCust);
                }

                //保存客户信息,得到更新的entity.CustID
                this.dataCtx.SubmitChanges();

                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Ejemplo n.º 3
0
        //获取输入数据
        private CRMCustomer GetNewCustomer(string CustName, long?CustOwnerID)
        {
            var entity = new CRMCustomer();

            entity.CustName       = CustName.Trim();
            entity.CustFullName   = CustName.Trim();
            entity.CustTypeID     = 3;
            entity.CustRelationID = 6;
            entity.CustIndustryID = 1;
            //entity.CustEmpNumID = 1;
            //entity.CustCountryID = 37; //china
            entity.CustCDate   = DateTime.Now;
            entity.CustCUserID = base.LoginUserID;
            if (CustOwnerID == null)
            {
                entity.CustOwnerID = 0;
            }
            else
            {
                entity.CustOwnerID = (long)CustOwnerID;
            }
            entity.SYSID            = 1;
            entity.CustModifyDate   = DateTime.Now;
            entity.CustModifyUserID = base.LoginUserID;
            entity.CommissionFactor = 1.0;
            entity.IsActive         = true;
            entity.Status           = "A";

            //Ticket Fields
            if (CustName.Contains(" MRS"))
            {
                entity.Gender = "F";
            }
            else
            {
                entity.Gender = "M";
            }

            return(entity);
        }
Ejemplo n.º 4
0
        public void ApprovePendingCustomer(CRMCustomer entity)
        {
            if (this.dataCtx.Connection != null)
            {
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                {
                    this.dataCtx.Connection.Open();
                }
            }
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();

            dataCtx.Transaction = tran;

            try
            {
                var qry = from t in CRMCustomers
                          where t.CustID == entity.CustID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    obj.Status = "A";
                }

                //保存客户信息,得到更新的entity.CustID
                this.dataCtx.SubmitChanges();
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Ejemplo n.º 5
0
        public void SetSatusCrm(CRMCustomer crm)
        {
            bool          isCancel   = false;
            CRMStatusCode code       = CRMStatusCode.Potential;
            DateTime      cancelDate = crm.DateCancel ?? crm.CreatedDate.Date;

            DateTime lastCancelDate = cancelDate.AddDays(days);

            if (crm.SsmCusId.HasValue)
            {
                var shipments = shipmentServices.Count(s => s.CneeId.Value == crm.SsmCusId.Value || s.ShipperId.Value == crm.SsmCusId.Value);
                if (shipments == 0)
                {
                    code = CRMStatusCode.Potential;
                }
                if (shipments >= 1)
                {
                    code = CRMStatusCode.Success;
                }
            }
            else
            {
                if (lastCancelDate < DateTime.Today)
                {
                    isCancel = true;
                    code     = CRMStatusCode.Client;
                }
            }

            var status = statusService.GetModel(code);

            if (crm.CRMStatus.Code == (byte)code)
            {
                return;
            }
            crmService.SetStatus(crm.Id, status.Id, code, isCancel);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// A 内部订单号
        /// B 客人姓名 title
        /// C售价
        /// D备注
        /// E负责销售人员
        /// F机票号
        /// G Amadeus预订号
        /// H 起飞日期
        /// </summary>
        /// <param name="filename"></param>
        private void ExtractExcelData(string filename)
        {
            CRMCustomerDeal Deal;
            FileStream      file = new FileStream(filename, FileMode.Open);
            HSSFWorkbook    wb   = new HSSFWorkbook(file);
            HSSFSheet       sht;

            sht = wb.GetSheetAt(0); //取第一个sheet
            //取行Excel的最大行数
            int rowsCount = sht.PhysicalNumberOfRows;

            //第1行是header,不是数据
            for (int i = 1; i < rowsCount; i++)
            {
                //如果内部订单号是空,跳过
                if (sht.GetStringCellValue(i, "A") == "")
                {
                    continue;
                }

                Deal             = new CRMCustomerDeal();
                Deal.ContractNum = sht.GetStringCellValue(i, "A");
                //如果单元格为空,GetCell方法会返回null,自己定义个扩展方法返回非空
                string UserName = sht.GetStringCellValue(i, "E");
                var    objUser  = usr.LoadByUserName(UserName);
                if (objUser != null)
                {
                    Deal.DealOwner = objUser.UserID;
                }
                //产品序列号,机票号
                Deal.ProdSerialNum = sht.GetStringCellValue(i, "F");
                //外部amadeus订单号
                Deal.ReferenceNum = sht.GetStringCellValue(i, "G");


                try
                {
                    Deal.DealDate = Convert.ToDateTime(sht.GetDateCellValue(i, "H"));
                }
                catch { }

                string CustName = sht.GetStringCellValue(i, "B");
                long   CustID   = cus.GetCustIDByName(CustName);
                if (CustID > 0)
                {
                    Deal.CustID = CustID;
                }
                else
                {
                    //新建一个客户
                    CRMCustomer entity = GetNewCustomer(CustName, Deal.DealOwner);
                    entity      = cus.Save(entity, null);
                    Deal.CustID = entity.CustID;
                }
                Deal.ProdID = 1;//现暂固定为1=机票
                Deal.Qty    = 1;
                Deal.Unit   = "PCS";
                try
                {
                    Deal.UnitPrice = Convert.ToDecimal(sht.GetStringCellValue(i, "C"));
                    //Deal.UnitPrice = Convert.ToDecimal(sht.GetStringCellValue(i, "C"));
                }
                catch (Exception)
                {
                    Deal.UnitPrice = 0;
                }
                Deal.TotalAmount = Deal.UnitPrice;
                Deal.Currency    = "EUR";
                Deal.Remark      = sht.GetStringCellValue(i, "D");
                //现在CANX是取消,是放在客户名字里,但是否应该分开单列一列?
                if (CustName.Contains("(CANX)"))
                {
                    Deal.Status = 1; //取消
                }
                else
                {
                    Deal.Status = 0; //正常
                }
                Deal.CreateDate   = DateTime.Now;
                Deal.CreateUserID = base.LoginUserID;
                Deal.ModifyDate   = DateTime.Now;
                Deal.ModifyUserID = base.LoginUserID;


                try
                {
                    cus.SaveDeal(Deal);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message + Deal.ContractNum + " ");
                    this.ShowMessage("Please check " + Deal.ContractNum + " " + ex.Message);
                }
            }
            file.Close();
        }
Ejemplo n.º 7
0
        //�ѵ�ǰ��¼copy����ʷ��
        private void CopyToHistory(CRMCustomer obj)
        {
            long NextVersion;

            var qry = CRMCustomerProdHistorys.Where(t => t.CustID == obj.CustID);

            if (qry.Count() > 0)
                NextVersion = qry.Max(t => t.Version) + 1;
            else
                NextVersion = 1;

            CRMCustomerHistory h = new CRMCustomerHistory();
            h.Version = NextVersion;
            h.BirthDay = obj.BirthDay;
            h.BuddyList = obj.BuddyList;
            h.Budget = obj.Budget;
            h.CommissionFactor = obj.CommissionFactor;
            h.CRMCustomer = obj;
            h.CustAddress = obj.CustAddress;
            h.CustBackground = obj.CustBackground;
            h.CustCity = obj.CustCity;
            h.CustCode = obj.CustCode == null ? obj.CustID.ToString() : obj.CustCode;
            h.CustCountryID = obj.CustCountryID;
            h.CustDistinct = obj.CustDistinct;
            h.CustEmpNumID = obj.CustEmpNumID;
            h.CustFax = obj.CustFax;
            h.CustFromID = obj.CustFromID;
            h.CustFullName = obj.CustFullName;
            h.CustID = obj.CustID;
            h.CustIndustryID = obj.CustIndustryID;
            h.CustInfo = obj.CustInfo;
            h.CustMaterial = obj.CustMaterial;
            h.CustName = obj.CustName;
            h.CustOwnerID = obj.CustOwnerID;
            h.CustPayMethod = obj.CustPayMethod;
            h.CustPort = obj.CustPort;
            h.CustProvince = obj.CustProvince;
            h.CustPurchaseChannels = obj.CustPurchaseChannels;
            h.CustRelationID = obj.CustRelationID;
            h.CustRisk = obj.CustRisk;
            h.CustSaleChannels = obj.CustSaleChannels;
            h.CustStatusID = obj.CustStatusID;
            h.CustTel = obj.CustTel;
            h.CustTypeID = obj.CustTypeID;
            h.CustWeb = obj.CustWeb;
            h.FavoriteDest = obj.FavoriteDest;
            h.FavoriteProd = obj.FavoriteProd;
            h.Gender = obj.Gender;
            h.ParentCompany = obj.ParentCompany;
            h.Passport = obj.Passport;
            h.PassportExpiryDate = obj.PassportExpiryDate;
            h.Position = obj.Position;
            h.PreferPlace = obj.PreferPlace;
            h.PreferPrice = obj.PreferPrice;
            h.RequireVisa = obj.RequireVisa;
            h.Status = obj.Status;
            h.TravelDay = obj.TravelDay;
            h.UseOwnMoney = obj.UseOwnMoney;
            h.SYSID = obj.SYSID;

            this.CRMCustomerHistorys.InsertOnSubmit(h);

            var oldList = CRMCustomerProds.Where(t => t.CustID == obj.CustID).ToList();
            foreach (var item in oldList)
            {
                CRMCustomerProdHistory cph = new CRMCustomerProdHistory();
                cph.Brand = item.Brand;
                cph.CustID = item.CustID;
                cph.ProdID = item.ProdID;
                cph.Remark = item.Remark;
                cph.Usage = item.Usage;
                cph.Version = NextVersion;
                this.CRMCustomerProdHistorys.InsertOnSubmit(cph);
            }
            //ɾ���ɵ�Customer Products
            this.CRMCustomerProds.DeleteAllOnSubmit(oldList);
        }
Ejemplo n.º 8
0
        //���бȽϿͻ�������
        private void AddAuditLog(CRMCustomer oldCust, CRMCustomer newCust)
        {
            #region ID to Name using DataTable Select Method

            DataTable dtCustType = base.GetCustType();
            DataTable dtCustRelation = base.GetCustRelation();
            //DataTable dtCustIndustry = base.GetCustIndustry();
            DataTable dtCustEmpNum = base.GetCustEmpNum();
            DataTable dtCountry = base.GetCountry();
            DataTable dtUser = base.GetUser();

            string oldCustType = "", newCustType;
            string oldCustRelation, newCustRelation;
            //string oldCustIndustry, newCustIndustry;
            string oldCustEmpNum, newCustEmpNum;
            string oldCountry, newCountry;
            string oldOwner="", newOwner="";

            if (oldCust.CustOwnerID == 0)
                oldOwner = "";
            else
            {
                var drs =dtUser.Select("UserID=" + oldCust.CustOwnerID);
                if (drs.Length > 0)
                    oldOwner = drs[0]["UserFullName"].ToString();
                else
                    oldOwner = "";
            }
            if(newCust.CustOwnerID!=0)
            {
                var drs = dtUser.Select("UserID=" + newCust.CustOwnerID);
                newOwner = drs[0]["UserFullName"].ToString();
            }

            //-------------------------------------
            oldCustType = dtCustType.Select("CustTypeID=" + oldCust.CustTypeID)[0]["CustType"].ToString();
            newCustType = dtCustType.Select("CustTypeID=" + newCust.CustTypeID)[0]["CustType"].ToString();
            //-------------------------------------
            if (oldCust.CustRelationID == null)
                oldCustRelation = "";
            else
            {
                DataRow[] drs = dtCustRelation.Select("RelationID=" + oldCust.CustRelationID);
                if (drs.Length > 0)
                    oldCustRelation = drs[0]["Relation"].ToString();
                else
                    oldCustRelation = "";
            }
            newCustRelation = dtCustRelation.Select("RelationID=" + newCust.CustRelationID)[0]["Relation"].ToString();
            //-------------------------------------
            if (oldCust.CustCountryID == null)
                oldCountry = "";
            else
            {
                DataRow[] drs = dtCountry.Select("CountryID=" + oldCust.CustCountryID);
                if (drs.Length > 0)
                    oldCountry = drs[0]["Country"].ToString();
                else
                    oldCountry = "";
            }
            if (newCust.CustCountryID == null)
                newCountry = "";
            else
                newCountry = dtCountry.Select("CountryID=" + newCust.CustCountryID)[0]["Country"].ToString();
            //-------------------------------------
            if (oldCust.CustEmpNumID == null)
                oldCustEmpNum = "";
            else
            {
                DataRow[] drs = dtCustEmpNum.Select("ID=" + oldCust.CustEmpNumID);
                if (drs.Length > 0)
                    oldCustEmpNum = drs[0]["EmpNum"].ToString();
                else
                    oldCustEmpNum = "";
            }
            if (newCust.CustEmpNumID == null)
                newCustEmpNum = "";
            else
                newCustEmpNum = dtCustEmpNum.Select("ID=" + newCust.CustEmpNumID)[0]["EmpNum"].ToString();
            //-------------------------------------
            #endregion

            CRMAuditLog Log = new CRMAuditLog();
            Log.Action = "SaveCustomer"; //������ʾʱ��ת�ɶ����� SaveCustomer,SaveDeal,SaveUser
            Log.ActionAt = DateTime.Now;
            Log.ActionBy = newCust.CustModifyUserID;
            Log.PKId = newCust.CustID;
            string ActionLog = "";

            if (oldCust.CustOwnerID != newCust.CustOwnerID)
                ActionLog += "����������Ա:" + oldOwner + "=>" + newOwner + " ;";

            if (oldCust.IsActive != newCust.IsActive)
                ActionLog += "IsActive:" + oldCust.IsActive + "=>" + newCust.IsActive + " ;";
            if (oldCust.CustCode != newCust.CustCode)
                ActionLog += "�ͻ�����:" + oldCust.CustCode + "=>" + newCust.CustCode + " ;";
            if (oldCust.CustName != newCust.CustName)
                ActionLog += "�ͻ����:" + oldCust.CustName + "=>" + newCust.CustName + " ;";
            if (oldCust.CustFullName != newCust.CustFullName)
                ActionLog += "�ͻ�ȫ��:" + oldCust.CustCode + "=>" + newCust.CustCode + " ;";

            if (oldCust.CustTypeID != newCust.CustTypeID)
                ActionLog += "�ͻ�����:" + oldCustType + "=>" + newCustType + " ;";

            if (oldCust.CustRelationID != newCust.CustRelationID)
                ActionLog += "�ͻ�����:" + oldCustRelation + "=>" + newCustRelation + " ;";

            if (oldCust.CustPayMethod != newCust.CustPayMethod)
                ActionLog += "���ʽ:" + oldCust.CustPayMethod + "=>" + newCust.CustPayMethod + " ;";
            if (oldCust.CustEmail != newCust.CustEmail)
                ActionLog += "����:" + oldCust.CustEmail + "=>" + newCust.CustEmail + " ;";
            if (oldCust.CustProvince != newCust.CustProvince)
                ActionLog += "ʡ��:" + oldCust.CustProvince + "=>" + newCust.CustProvince + " ;";
            if (oldCust.CustAddress != newCust.CustAddress)
                ActionLog += "�ͻ���ַ:" + oldCust.CustAddress + "=>" + newCust.CustAddress + " ;";
            if (oldCust.CustTel != newCust.CustTel)
                ActionLog += "�绰:" + oldCust.CustTel + "=>" + newCust.CustTel + " ;";
            if (oldCust.CustFax != newCust.CustFax)
                ActionLog += "����:" + oldCust.CustFax + "=>" + newCust.CustFax + " ;";
            if (oldCust.CustWeb != newCust.CustWeb)
                ActionLog += "��ַ:" + oldCust.CustWeb + "=>" + newCust.CustWeb + " ;";

            //ticket
            if (ConfigurationManager.AppSettings["Industry"].ToLower() == "ticket")
            {
                if (oldCust.Gender != newCust.Gender)
                    ActionLog += "�Ա�:" + oldCust.Gender + "=>" + newCust.Gender + " ;";
                if (oldCust.BirthDay != newCust.BirthDay)
                    ActionLog += "����:" + oldCust.BirthDay + "=>" + newCust.BirthDay + " ;";

                if (oldCust.CustCountryID != newCust.CustCountryID)
                    ActionLog += "����:" + oldCountry + "=>" + newCountry + " ;";

                if (oldCust.Passport != newCust.Passport)
                    ActionLog += "����:" + oldCust.Passport + "=>" + newCust.Passport + " ;";
                if (oldCust.PassportExpiryDate != newCust.PassportExpiryDate)
                    ActionLog += "��������:" + oldCust.PassportExpiryDate + "=>" + newCust.PassportExpiryDate + " ;";
                if (oldCust.RequireVisa != newCust.RequireVisa)
                    ActionLog += "ÿ�ζ�ǩ֤:" + oldCust.RequireVisa + "=>" + newCust.RequireVisa + " ;";
                if (oldCust.ParentCompany != newCust.ParentCompany)
                    ActionLog += "�����˾:" + oldCust.ParentCompany + "=>" + newCust.ParentCompany + " ;";
                if (oldCust.Position != newCust.Position)
                    ActionLog += "ְλ:" + oldCust.Position + "=>" + newCust.Position + " ;";
                if (oldCust.UseOwnMoney != newCust.UseOwnMoney)
                    ActionLog += "���Լ�Ǯ:" + oldCust.UseOwnMoney + "=>" + newCust.UseOwnMoney + " ;";

                if (oldCust.CustEmpNumID != newCust.CustEmpNumID)
                    ActionLog += "��˾��ģ:" + oldCustEmpNum + "=>" + newCustEmpNum + " ;";

                if (oldCust.FavoriteProd != newCust.FavoriteProd)
                    ActionLog += "ϲ�ú��չ�˾:" + oldCust.FavoriteProd + "=>" + newCust.FavoriteProd + " ;";
                if (oldCust.PreferPrice != newCust.PreferPrice)
                    ActionLog += "��λϲ��:" + oldCust.PreferPrice + "=>" + newCust.PreferPrice + " ;";
                if (oldCust.PreferPlace != newCust.PreferPlace)
                    ActionLog += "��ɵص�:" + oldCust.PreferPlace + "=>" + newCust.PreferPlace + " ;";
                if (oldCust.FavoriteDest != newCust.FavoriteDest)
                    ActionLog += "��ȥ����:" + oldCust.FavoriteDest + "=>" + newCust.FavoriteDest + " ;";
                if (oldCust.Budget != newCust.Budget)
                    ActionLog += "����Ԥ��:" + oldCust.Budget + "=>" + newCust.Budget + " ;";
                if (oldCust.TravelDay != newCust.TravelDay)
                    ActionLog += "ÿ�����ʱ��:" + oldCust.TravelDay + "=>" + newCust.TravelDay + " ;";

                if (IsNull(oldCust.BuddyList) != newCust.BuddyList)
                    ActionLog += "��������:" + GetBuddyNameList(oldCust.BuddyList) +
                        "=>" + GetBuddyNameList(newCust.BuddyList) + " ;";
            }
            //chemical
            if (ConfigurationManager.AppSettings["Industry"].ToLower() == "chemical")
            {
                if (oldCust.CustPort != newCust.CustPort)
                    ActionLog += "�ӻ��ۿ�:" + oldCust.CustPort + "=>" + newCust.CustPort + " ;";
                if (oldCust.CustPurchaseChannels != newCust.CustPurchaseChannels)
                    ActionLog += "��������:" + oldCust.CustPurchaseChannels + "=>" + newCust.CustPurchaseChannels + " ;";
                if (oldCust.CustSaleChannels != newCust.CustSaleChannels)
                    ActionLog += "����;��:" + oldCust.CustSaleChannels + "=>" + newCust.CustSaleChannels + " ;";
                if (oldCust.CommissionFactor != newCust.CommissionFactor)
                    ActionLog += "�ͻ�ϵ��:" + oldCust.CommissionFactor + "=>" + newCust.CommissionFactor + " ;";
                if (oldCust.CustMaterial != newCust.CustMaterial)
                    ActionLog += "ʹ���ҹ�˾��Ʒ�����:" + oldCust.CustMaterial + "=>" + newCust.CustMaterial + " ;";
                if (oldCust.CustProduct != newCust.CustProduct)
                    ActionLog += "�ͻ�������Ʒ:" + oldCust.CustProduct + "=>" + newCust.CustProduct + " ;";
                if (oldCust.CustInfo != newCust.CustInfo)
                    ActionLog += "�ɹ�ϰ��:" + oldCust.CustInfo + "=>" + newCust.CustInfo + " ;";
            }
            Log.ActionLog = ActionLog;

            this.CRMAuditLogs.InsertOnSubmit(Log);
        }
Ejemplo n.º 9
0
        //现在不直接update旧记录,而是把旧记录copy到history表,再update customer to status=Pending
        //Boss 审批之后,把customer's status = Active
        public CRMCustomer Save(CRMCustomer entity, IList <CRMCustomerProd> LstCP)
        {
            if (this.dataCtx.Connection != null)
            {
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                {
                    this.dataCtx.Connection.Open();
                }
            }
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();

            dataCtx.Transaction = tran;

            try
            {
                var qry = from t in CRMCustomers
                          where t.CustID == entity.CustID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    //把旧记录copy到history表,删除旧的CRMCustomerProds
                    CopyToHistory(obj);
                    //对比新旧记录,增加auditlog
                    this.AddAuditLog(obj, entity);
                    //赋值
                    this.CopyEntity(obj, entity);
                }
                else
                {
                    this.CRMCustomers.InsertOnSubmit(entity);
                }

                //保存客户信息,得到更新的entity.CustID
                this.dataCtx.SubmitChanges();

                ////现在自动生成客户编码,改用拼音首字母
                //entity.CustCode = entity.CustID.ToString();
                if (LstCP != null)
                {
                    foreach (var cp in LstCP)
                    {
                        //如果是新增客户信息,custid=0,要赋值
                        if (cp.CustID == 0)
                        {
                            cp.CustID = entity.CustID;
                        }

                        this.CRMCustomerProds.InsertOnSubmit(cp);
                    }
                }
                this.dataCtx.SubmitChanges();
                tran.Commit();
                return(entity);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Ejemplo n.º 10
0
        public void RejectPendingCustomer(CRMCustomer entity)
        {
            if (this.dataCtx.Connection != null)
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                    this.dataCtx.Connection.Open();
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();
            dataCtx.Transaction = tran;

            try
            {
                long MaxVersion = CRMCustomerHistorys.Where(t => t.CustID == entity.CustID).Max(t => t.Version);
                var qry = from t in CRMCustomerHistorys
                          where t.CustID == entity.CustID && t.Version == MaxVersion
                          select t;
                var OldCust = qry.SingleOrDefault();
                if (OldCust != null)
                {
                    //����ʷ��ɼ�¼copy��Customer��
                    this.CopyEntity(entity, OldCust);

                }

                //����ͻ���Ϣ,�õ����µ�entity.CustID
                this.dataCtx.SubmitChanges();

                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Ejemplo n.º 11
0
        //������ֲ�����,����һ��cust
        public long GetCustIDByName(string CustName, string CustAddress, string CustTel,
            string CustEmail, long Creator, long Owner, bool CreateIfNotExist)
        {
            var qry = from t in vw_CRMCustomers
                      where t.CustName == CustName && t.IsActive==true
                      select t;
            var lst = qry.ToList();
            if (lst.Count > 0)
            {
                return lst[0].CustID;
            }
            else
            {
                if (CreateIfNotExist)
                {
                    var qry1 = from t in CRMCustomers
                              where t.CustName == CustName
                              select t;

                    if (qry1.ToList().Count > 0)
                    {
                        var InactiveCust = qry1.SingleOrDefault();
                        InactiveCust.IsActive = true;
                        return Save(InactiveCust, null).CustID;
                    }

                    CRMCustomer entity = new CRMCustomer();
                    if (CustName.Contains("MRS"))
                        entity.Gender = "F";
                    else
                        entity.Gender = "M";
                    entity.CustName = CustName;
                    entity.CustFullName = CustName;
                    entity.CustAddress = CustAddress;
                    entity.CustEmail = CustEmail;
                    entity.CustTel = CustTel;
                    entity.CustTypeID = 3; // ��ͨ����
                    entity.CustRelationID = 6; //�����ö��
                    entity.CommissionFactor = 1;
                    entity.IsActive = true;
                    entity.Status = "A";
                    entity.CustCDate = DateTime.Now;
                    entity.CustCUserID = Creator;
                    entity.CustOwnerID = Owner;
                    entity.SYSID = 1;
                    entity.CustModifyDate = DateTime.Now;
                    entity.CustModifyUserID = Creator;
                    entity = Save(entity, null);
                    return entity.CustID;

                }
                else
                    return 0;
            }
        }
Ejemplo n.º 12
0
        //如果名字不存在,新增一个cust
        public long GetCustIDByName(string CustName, string CustAddress, string CustTel,
                                    string CustEmail, long Creator, long Owner, bool CreateIfNotExist)
        {
            var qry = from t in vw_CRMCustomers
                      where t.CustName == CustName && t.IsActive == true
                      select t;
            var lst = qry.ToList();

            if (lst.Count > 0)
            {
                return(lst[0].CustID);
            }
            else
            {
                if (CreateIfNotExist)
                {
                    var qry1 = from t in CRMCustomers
                               where t.CustName == CustName
                               select t;

                    if (qry1.ToList().Count > 0)
                    {
                        var InactiveCust = qry1.SingleOrDefault();
                        InactiveCust.IsActive = true;
                        return(Save(InactiveCust, null).CustID);
                    }

                    CRMCustomer entity = new CRMCustomer();
                    if (CustName.Contains("MRS"))
                    {
                        entity.Gender = "F";
                    }
                    else
                    {
                        entity.Gender = "M";
                    }
                    entity.CustName         = CustName;
                    entity.CustFullName     = CustName;
                    entity.CustAddress      = CustAddress;
                    entity.CustEmail        = CustEmail;
                    entity.CustTel          = CustTel;
                    entity.CustTypeID       = 3; // 普通客人
                    entity.CustRelationID   = 6; //无信用额度
                    entity.CommissionFactor = 1;
                    entity.IsActive         = true;
                    entity.Status           = "A";
                    entity.CustCDate        = DateTime.Now;
                    entity.CustCUserID      = Creator;
                    entity.CustOwnerID      = Owner;
                    entity.SYSID            = 1;
                    entity.CustModifyDate   = DateTime.Now;
                    entity.CustModifyUserID = Creator;
                    entity = Save(entity, null);
                    return(entity.CustID);
                }
                else
                {
                    return(0);
                }
            }
        }
Ejemplo n.º 13
0
        //逐行比较客户的属性
        private void AddAuditLog(CRMCustomer oldCust, CRMCustomer newCust)
        {
            #region ID to Name using DataTable Select Method

            DataTable dtCustType     = base.GetCustType();
            DataTable dtCustRelation = base.GetCustRelation();
            //DataTable dtCustIndustry = base.GetCustIndustry();
            DataTable dtCustEmpNum = base.GetCustEmpNum();
            DataTable dtCountry    = base.GetCountry();
            DataTable dtUser       = base.GetUser();

            string oldCustType = "", newCustType;
            string oldCustRelation, newCustRelation;
            //string oldCustIndustry, newCustIndustry;
            string oldCustEmpNum, newCustEmpNum;
            string oldCountry, newCountry;
            string oldOwner = "", newOwner = "";

            if (oldCust.CustOwnerID == 0)
            {
                oldOwner = "";
            }
            else
            {
                var drs = dtUser.Select("UserID=" + oldCust.CustOwnerID);
                if (drs.Length > 0)
                {
                    oldOwner = drs[0]["UserFullName"].ToString();
                }
                else
                {
                    oldOwner = "";
                }
            }
            if (newCust.CustOwnerID != 0)
            {
                var drs = dtUser.Select("UserID=" + newCust.CustOwnerID);
                newOwner = drs[0]["UserFullName"].ToString();
            }

            //-------------------------------------
            oldCustType = dtCustType.Select("CustTypeID=" + oldCust.CustTypeID)[0]["CustType"].ToString();
            newCustType = dtCustType.Select("CustTypeID=" + newCust.CustTypeID)[0]["CustType"].ToString();
            //-------------------------------------
            if (oldCust.CustRelationID == null)
            {
                oldCustRelation = "";
            }
            else
            {
                DataRow[] drs = dtCustRelation.Select("RelationID=" + oldCust.CustRelationID);
                if (drs.Length > 0)
                {
                    oldCustRelation = drs[0]["Relation"].ToString();
                }
                else
                {
                    oldCustRelation = "";
                }
            }
            newCustRelation = dtCustRelation.Select("RelationID=" + newCust.CustRelationID)[0]["Relation"].ToString();
            //-------------------------------------
            if (oldCust.CustCountryID == null)
            {
                oldCountry = "";
            }
            else
            {
                DataRow[] drs = dtCountry.Select("CountryID=" + oldCust.CustCountryID);
                if (drs.Length > 0)
                {
                    oldCountry = drs[0]["Country"].ToString();
                }
                else
                {
                    oldCountry = "";
                }
            }
            if (newCust.CustCountryID == null)
            {
                newCountry = "";
            }
            else
            {
                newCountry = dtCountry.Select("CountryID=" + newCust.CustCountryID)[0]["Country"].ToString();
            }
            //-------------------------------------
            if (oldCust.CustEmpNumID == null)
            {
                oldCustEmpNum = "";
            }
            else
            {
                DataRow[] drs = dtCustEmpNum.Select("ID=" + oldCust.CustEmpNumID);
                if (drs.Length > 0)
                {
                    oldCustEmpNum = drs[0]["EmpNum"].ToString();
                }
                else
                {
                    oldCustEmpNum = "";
                }
            }
            if (newCust.CustEmpNumID == null)
            {
                newCustEmpNum = "";
            }
            else
            {
                newCustEmpNum = dtCustEmpNum.Select("ID=" + newCust.CustEmpNumID)[0]["EmpNum"].ToString();
            }
            //-------------------------------------
            #endregion

            CRMAuditLog Log = new CRMAuditLog();
            Log.Action   = "SaveCustomer"; //界面显示时再转成多语言 SaveCustomer,SaveDeal,SaveUser
            Log.ActionAt = DateTime.Now;
            Log.ActionBy = newCust.CustModifyUserID;
            Log.PKId     = newCust.CustID;
            string ActionLog = "";

            if (oldCust.CustOwnerID != newCust.CustOwnerID)
            {
                ActionLog += "所属销售人员:" + oldOwner + "=>" + newOwner + " ;";
            }

            if (oldCust.IsActive != newCust.IsActive)
            {
                ActionLog += "IsActive:" + oldCust.IsActive + "=>" + newCust.IsActive + " ;";
            }
            if (oldCust.CustCode != newCust.CustCode)
            {
                ActionLog += "客户编码:" + oldCust.CustCode + "=>" + newCust.CustCode + " ;";
            }
            if (oldCust.CustName != newCust.CustName)
            {
                ActionLog += "客户简称:" + oldCust.CustName + "=>" + newCust.CustName + " ;";
            }
            if (oldCust.CustFullName != newCust.CustFullName)
            {
                ActionLog += "客户全名:" + oldCust.CustCode + "=>" + newCust.CustCode + " ;";
            }

            if (oldCust.CustTypeID != newCust.CustTypeID)
            {
                ActionLog += "客户类型:" + oldCustType + "=>" + newCustType + " ;";
            }

            if (oldCust.CustRelationID != newCust.CustRelationID)
            {
                ActionLog += "客户级别:" + oldCustRelation + "=>" + newCustRelation + " ;";
            }

            if (oldCust.CustPayMethod != newCust.CustPayMethod)
            {
                ActionLog += "付款方式:" + oldCust.CustPayMethod + "=>" + newCust.CustPayMethod + " ;";
            }
            if (oldCust.CustEmail != newCust.CustEmail)
            {
                ActionLog += "电邮:" + oldCust.CustEmail + "=>" + newCust.CustEmail + " ;";
            }
            if (oldCust.CustProvince != newCust.CustProvince)
            {
                ActionLog += "省份:" + oldCust.CustProvince + "=>" + newCust.CustProvince + " ;";
            }
            if (oldCust.CustAddress != newCust.CustAddress)
            {
                ActionLog += "客户地址:" + oldCust.CustAddress + "=>" + newCust.CustAddress + " ;";
            }
            if (oldCust.CustTel != newCust.CustTel)
            {
                ActionLog += "电话:" + oldCust.CustTel + "=>" + newCust.CustTel + " ;";
            }
            if (oldCust.CustFax != newCust.CustFax)
            {
                ActionLog += "传真:" + oldCust.CustFax + "=>" + newCust.CustFax + " ;";
            }
            if (oldCust.CustWeb != newCust.CustWeb)
            {
                ActionLog += "网址:" + oldCust.CustWeb + "=>" + newCust.CustWeb + " ;";
            }

            //ticket
            if (ConfigurationManager.AppSettings["Industry"].ToLower() == "ticket")
            {
                if (oldCust.Gender != newCust.Gender)
                {
                    ActionLog += "性别:" + oldCust.Gender + "=>" + newCust.Gender + " ;";
                }
                if (oldCust.BirthDay != newCust.BirthDay)
                {
                    ActionLog += "生日:" + oldCust.BirthDay + "=>" + newCust.BirthDay + " ;";
                }

                if (oldCust.CustCountryID != newCust.CustCountryID)
                {
                    ActionLog += "国籍:" + oldCountry + "=>" + newCountry + " ;";
                }

                if (oldCust.Passport != newCust.Passport)
                {
                    ActionLog += "护照:" + oldCust.Passport + "=>" + newCust.Passport + " ;";
                }
                if (oldCust.PassportExpiryDate != newCust.PassportExpiryDate)
                {
                    ActionLog += "护照有效期:" + oldCust.PassportExpiryDate + "=>" + newCust.PassportExpiryDate + " ;";
                }
                if (oldCust.RequireVisa != newCust.RequireVisa)
                {
                    ActionLog += "每次都签证:" + oldCust.RequireVisa + "=>" + newCust.RequireVisa + " ;";
                }
                if (oldCust.ParentCompany != newCust.ParentCompany)
                {
                    ActionLog += "所属公司:" + oldCust.ParentCompany + "=>" + newCust.ParentCompany + " ;";
                }
                if (oldCust.Position != newCust.Position)
                {
                    ActionLog += "职位:" + oldCust.Position + "=>" + newCust.Position + " ;";
                }
                if (oldCust.UseOwnMoney != newCust.UseOwnMoney)
                {
                    ActionLog += "花自己钱:" + oldCust.UseOwnMoney + "=>" + newCust.UseOwnMoney + " ;";
                }

                if (oldCust.CustEmpNumID != newCust.CustEmpNumID)
                {
                    ActionLog += "公司规模:" + oldCustEmpNum + "=>" + newCustEmpNum + " ;";
                }

                if (oldCust.FavoriteProd != newCust.FavoriteProd)
                {
                    ActionLog += "喜好航空公司:" + oldCust.FavoriteProd + "=>" + newCust.FavoriteProd + " ;";
                }
                if (oldCust.PreferPrice != newCust.PreferPrice)
                {
                    ActionLog += "舱位喜好:" + oldCust.PreferPrice + "=>" + newCust.PreferPrice + " ;";
                }
                if (oldCust.PreferPlace != newCust.PreferPlace)
                {
                    ActionLog += "起飞地点:" + oldCust.PreferPlace + "=>" + newCust.PreferPlace + " ;";
                }
                if (oldCust.FavoriteDest != newCust.FavoriteDest)
                {
                    ActionLog += "常去城市:" + oldCust.FavoriteDest + "=>" + newCust.FavoriteDest + " ;";
                }
                if (oldCust.Budget != newCust.Budget)
                {
                    ActionLog += "消费预算:" + oldCust.Budget + "=>" + newCust.Budget + " ;";
                }
                if (oldCust.TravelDay != newCust.TravelDay)
                {
                    ActionLog += "每年飞行时段:" + oldCust.TravelDay + "=>" + newCust.TravelDay + " ;";
                }

                if (IsNull(oldCust.BuddyList) != newCust.BuddyList)
                {
                    ActionLog += "亲友名单:" + GetBuddyNameList(oldCust.BuddyList) +
                                 "=>" + GetBuddyNameList(newCust.BuddyList) + " ;";
                }
            }
            //chemical
            if (ConfigurationManager.AppSettings["Industry"].ToLower() == "chemical")
            {
                if (oldCust.CustPort != newCust.CustPort)
                {
                    ActionLog += "接货港口:" + oldCust.CustPort + "=>" + newCust.CustPort + " ;";
                }
                if (oldCust.CustPurchaseChannels != newCust.CustPurchaseChannels)
                {
                    ActionLog += "进货渠道:" + oldCust.CustPurchaseChannels + "=>" + newCust.CustPurchaseChannels + " ;";
                }
                if (oldCust.CustSaleChannels != newCust.CustSaleChannels)
                {
                    ActionLog += "销售途径:" + oldCust.CustSaleChannels + "=>" + newCust.CustSaleChannels + " ;";
                }
                if (oldCust.CommissionFactor != newCust.CommissionFactor)
                {
                    ActionLog += "客户系数:" + oldCust.CommissionFactor + "=>" + newCust.CommissionFactor + " ;";
                }
                if (oldCust.CustMaterial != newCust.CustMaterial)
                {
                    ActionLog += "使用我公司产品的情况:" + oldCust.CustMaterial + "=>" + newCust.CustMaterial + " ;";
                }
                if (oldCust.CustProduct != newCust.CustProduct)
                {
                    ActionLog += "客户生产产品:" + oldCust.CustProduct + "=>" + newCust.CustProduct + " ;";
                }
                if (oldCust.CustInfo != newCust.CustInfo)
                {
                    ActionLog += "采购习惯:" + oldCust.CustInfo + "=>" + newCust.CustInfo + " ;";
                }
            }
            Log.ActionLog = ActionLog;

            this.CRMAuditLogs.InsertOnSubmit(Log);
        }
Ejemplo n.º 14
0
        //把当前记录copy到历史表
        private void CopyToHistory(CRMCustomer obj)
        {
            long NextVersion;

            var qry = CRMCustomerProdHistorys.Where(t => t.CustID == obj.CustID);

            if (qry.Count() > 0)
            {
                NextVersion = qry.Max(t => t.Version) + 1;
            }
            else
            {
                NextVersion = 1;
            }

            CRMCustomerHistory h = new CRMCustomerHistory();

            h.Version          = NextVersion;
            h.BirthDay         = obj.BirthDay;
            h.BuddyList        = obj.BuddyList;
            h.Budget           = obj.Budget;
            h.CommissionFactor = obj.CommissionFactor;
            h.CRMCustomer      = obj;
            h.CustAddress      = obj.CustAddress;
            h.CustBackground   = obj.CustBackground;
            h.CustCity         = obj.CustCity;
            h.CustCode         = obj.CustCode == null?obj.CustID.ToString() : obj.CustCode;

            h.CustCountryID        = obj.CustCountryID;
            h.CustDistinct         = obj.CustDistinct;
            h.CustEmpNumID         = obj.CustEmpNumID;
            h.CustFax              = obj.CustFax;
            h.CustFromID           = obj.CustFromID;
            h.CustFullName         = obj.CustFullName;
            h.CustID               = obj.CustID;
            h.CustIndustryID       = obj.CustIndustryID;
            h.CustInfo             = obj.CustInfo;
            h.CustMaterial         = obj.CustMaterial;
            h.CustName             = obj.CustName;
            h.CustOwnerID          = obj.CustOwnerID;
            h.CustPayMethod        = obj.CustPayMethod;
            h.CustPort             = obj.CustPort;
            h.CustProvince         = obj.CustProvince;
            h.CustPurchaseChannels = obj.CustPurchaseChannels;
            h.CustRelationID       = obj.CustRelationID;
            h.CustRisk             = obj.CustRisk;
            h.CustSaleChannels     = obj.CustSaleChannels;
            h.CustStatusID         = obj.CustStatusID;
            h.CustTel              = obj.CustTel;
            h.CustTypeID           = obj.CustTypeID;
            h.CustWeb              = obj.CustWeb;
            h.FavoriteDest         = obj.FavoriteDest;
            h.FavoriteProd         = obj.FavoriteProd;
            h.Gender               = obj.Gender;
            h.ParentCompany        = obj.ParentCompany;
            h.Passport             = obj.Passport;
            h.PassportExpiryDate   = obj.PassportExpiryDate;
            h.Position             = obj.Position;
            h.PreferPlace          = obj.PreferPlace;
            h.PreferPrice          = obj.PreferPrice;
            h.RequireVisa          = obj.RequireVisa;
            h.Status               = obj.Status;
            h.TravelDay            = obj.TravelDay;
            h.UseOwnMoney          = obj.UseOwnMoney;
            h.SYSID = obj.SYSID;

            this.CRMCustomerHistorys.InsertOnSubmit(h);

            var oldList = CRMCustomerProds.Where(t => t.CustID == obj.CustID).ToList();

            foreach (var item in oldList)
            {
                CRMCustomerProdHistory cph = new CRMCustomerProdHistory();
                cph.Brand   = item.Brand;
                cph.CustID  = item.CustID;
                cph.ProdID  = item.ProdID;
                cph.Remark  = item.Remark;
                cph.Usage   = item.Usage;
                cph.Version = NextVersion;
                this.CRMCustomerProdHistorys.InsertOnSubmit(cph);
            }
            //删除旧的Customer Products
            this.CRMCustomerProds.DeleteAllOnSubmit(oldList);
        }
Ejemplo n.º 15
0
        //获取输入数据
        private CRMCustomer GetSaveEntity()
        {
            var entity = new CRMCustomer();
            if (string.IsNullOrEmpty(hidID.Value.Trim()) == false)
                entity.CustID = int.Parse(hidID.Value.Trim());
            //现在CustCode改成自动生成
            //if (string.IsNullOrEmpty(txtCustCode.Text.Trim()) == false)
            //    entity.CustCode = txtCustCode.Text.Trim();
            entity.CustCode = PinYin.GetChineseSpell(txtCustName.Text);

            if (string.IsNullOrEmpty(txtCustName.Text.Trim()) == false)
                entity.CustName = txtCustName.Text.Trim();
            if (string.IsNullOrEmpty(txtCustFullName.Text.Trim()) == false)
                entity.CustFullName = txtCustFullName.Text.Trim();
            if (string.IsNullOrEmpty(txtCustTypeID.Text.Trim()) == false)
                entity.CustTypeID = int.Parse(txtCustTypeID.Text.Trim());
            if (string.IsNullOrEmpty(txtCustRelationID.Text.Trim()) == false)
                entity.CustRelationID = int.Parse(txtCustRelationID.Text.Trim());
            if (string.IsNullOrEmpty(txtCustIndustryID.Text.Trim()) == false)
                entity.CustIndustryID = int.Parse(txtCustIndustryID.Text.Trim());
            if (string.IsNullOrEmpty(txtCustEmpNumID.Text.Trim()) == false)
                entity.CustEmpNumID = int.Parse(txtCustEmpNumID.Text.Trim());
            if (string.IsNullOrEmpty(txtCustInfo.Text.Trim()) == false)
                entity.CustInfo = txtCustInfo.Text.Trim();
            if (string.IsNullOrEmpty(txtCustCountryID.Text.Trim()) == false)
                entity.CustCountryID = int.Parse(txtCustCountryID.Text.Trim());
            //只有选择了其他,才用textbox的值
            if (ddlProvince.Text == "其他")
            {
                if (string.IsNullOrEmpty(txtCustProvince.Text.Trim()) == false)
                    entity.CustProvince = txtCustProvince.Text.Trim();
            }
            else
            {
                entity.CustProvince = ddlProvince.Text;
            }

            if (string.IsNullOrEmpty(txtCustCity.Text.Trim()) == false)
                entity.CustCity = txtCustCity.Text.Trim();
            if (string.IsNullOrEmpty(txtCustDistinct.Text.Trim()) == false)
                entity.CustDistinct = txtCustDistinct.Text.Trim();
            if (string.IsNullOrEmpty(txtCustAddress.Text.Trim()) == false)
                entity.CustAddress = txtCustAddress.Text.Trim();
            if (string.IsNullOrEmpty(txtCustTel.Text.Trim()) == false)
                entity.CustTel = txtCustTel.Text.Trim();
            if (string.IsNullOrEmpty(txtCustFax.Text.Trim()) == false)
                entity.CustFax = txtCustFax.Text.Trim();
            if (string.IsNullOrEmpty(txtCustWeb.Text.Trim()) == false)
                entity.CustWeb = txtCustWeb.Text.Trim();
            if (string.IsNullOrEmpty(txtCustEmail.Text.Trim()) == false)
                entity.CustEmail = txtCustEmail.Text.Trim();
            if (string.IsNullOrEmpty(txtCustCDate.Text.Trim()) == false)
                entity.CustCDate = DateTime.Parse(txtCustCDate.Text.Trim());
            if (string.IsNullOrEmpty(txtCustCUserID.Value.Trim()) == false)
                entity.CustCUserID = int.Parse(txtCustCUserID.Value.Trim());
            if (string.IsNullOrEmpty(txtCustOwnerID.Text.Trim()) == false)
                entity.CustOwnerID = int.Parse(txtCustOwnerID.Text.Trim());
            if (string.IsNullOrEmpty(txtSYSID.Text.Trim()) == false)
                entity.SYSID = int.Parse(txtSYSID.Text.Trim());

            if (string.IsNullOrEmpty(txtArrivalPort.Text.Trim()) == false)
                entity.CustPort = txtArrivalPort.Text.Trim();
            if (string.IsNullOrEmpty(txtPayMethod.Text.Trim()) == false)
                entity.CustPayMethod = txtPayMethod.Text;
            if (string.IsNullOrEmpty(txtPurchaseChannels.Text.Trim()) == false)
                entity.CustPurchaseChannels = txtPurchaseChannels.Text;
            if (string.IsNullOrEmpty(txtSaleChannels.Text.Trim()) == false)
                entity.CustSaleChannels = txtSaleChannels.Text;
            if (string.IsNullOrEmpty(txtMaterial.Text.Trim()) == false)
                entity.CustMaterial = txtMaterial.Text;

            entity.CustModifyDate = DateTime.Now;
            entity.CustModifyUserID = base.LoginUserID;
            //entity.CustBidPrice = txtBidPrice.Text;
            double cf = 0.0;
            double.TryParse(txtCommissionFactor.Text, out cf);
            entity.CommissionFactor = cf;
            entity.CustProduct = txtCustProduct.Text;
            entity.IsActive = true;
            //??还没想好Status字段用途,P,A,还是审批流程步骤1,2,3,4
            entity.Status = "A";

            //Ticket Fields
            if (string.IsNullOrEmpty(ddlGender.Text) == false)
                entity.Gender = ddlGender.SelectedValue;
            if (string.IsNullOrEmpty(txtBirthday.Text) == false)
                entity.BirthDay = Convert.ToDateTime(txtBirthday.Text);

            if (string.IsNullOrEmpty(ddlPreferPrice.Text) == false)
                entity.PreferPrice = ddlPreferPrice.Text;
            if (string.IsNullOrEmpty(ddlUseOwnMoney.Text) == false)
                entity.UseOwnMoney = Convert.ToBoolean(ddlUseOwnMoney.Text);
            if (string.IsNullOrEmpty(ddlRequireVisa.Text) == false)
                entity.RequireVisa = Convert.ToBoolean(ddlRequireVisa.Text);
            if (string.IsNullOrEmpty(txtFavoriteDest.Text) == false)
                entity.FavoriteDest = txtFavoriteDest.Text;
            if (string.IsNullOrEmpty(txtFavoriteProd.Text) == false)
                entity.FavoriteProd = txtFavoriteProd.Text;
            if (string.IsNullOrEmpty(txtPreferPlace.Text) == false)
                entity.PreferPlace = txtPreferPlace.Text;
            if (string.IsNullOrEmpty(txtBudget.Text) == false)
                entity.Budget = txtBudget.Text;
            if (string.IsNullOrEmpty(txtPosition.Text) == false)
                entity.Position = txtPosition.Text;
            if (string.IsNullOrEmpty(txtParentCompany.Text) == false)
                entity.ParentCompany = txtParentCompany.Text;
            if (string.IsNullOrEmpty(txtPassport.Text) == false)
                entity.Passport = txtPassport.Text;
            if (string.IsNullOrEmpty(txtPassportExpiryDate.Text) == false)
                entity.PassportExpiryDate = txtPassportExpiryDate.Text;

            if (string.IsNullOrEmpty(chkTravelDay.Text) == false)
                entity.TravelDay = chkTravelDay.GetChecked(",");

                entity.BuddyList = BuddyList1.strBuddyList;
            return entity;
        }
Ejemplo n.º 16
0
        //���ڲ�ֱ��update�ɼ�¼,���ǰѾɼ�¼copy��history��,��update customer to status=Pending
        //Boss ����֮�󣬰�customer's status = Active
        public CRMCustomer Save(CRMCustomer entity, IList<CRMCustomerProd> LstCP)
        {
            if (this.dataCtx.Connection != null)
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                    this.dataCtx.Connection.Open();
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();
            dataCtx.Transaction = tran;

            try
            {
                var qry = from t in CRMCustomers
                          where t.CustID == entity.CustID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    //�Ѿɼ�¼copy��history��,ɾ���ɵ�CRMCustomerProds
                    CopyToHistory(obj);
                    //�Ա��¾ɼ�¼,����auditlog
                    this.AddAuditLog(obj, entity);
                    //��ֵ
                    this.CopyEntity(obj, entity);

                }
                else
                    this.CRMCustomers.InsertOnSubmit(entity);

                //����ͻ���Ϣ,�õ����µ�entity.CustID
                this.dataCtx.SubmitChanges();

                ////�����Զ����ɿͻ�����,����ƴ������ĸ
                //entity.CustCode = entity.CustID.ToString();
                if (LstCP != null)
                {
                    foreach (var cp in LstCP)
                    {
                        //����������ͻ���Ϣ��custid=0��Ҫ��ֵ
                        if (cp.CustID == 0)
                            cp.CustID = entity.CustID;

                        this.CRMCustomerProds.InsertOnSubmit(cp);

                    }
                }
                this.dataCtx.SubmitChanges();
                tran.Commit();
                return entity;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Ejemplo n.º 17
0
        //获取输入数据
        private CRMCustomer GetSaveEntity()
        {
            var entity = new CRMCustomer();

            if (string.IsNullOrEmpty(hidID.Value.Trim()) == false)
            {
                entity.CustID = int.Parse(hidID.Value.Trim());
            }
            //现在CustCode改成自动生成
            //if (string.IsNullOrEmpty(txtCustCode.Text.Trim()) == false)
            //    entity.CustCode = txtCustCode.Text.Trim();
            entity.CustCode = PinYin.GetChineseSpell(txtCustName.Text);

            if (string.IsNullOrEmpty(txtCustName.Text.Trim()) == false)
            {
                entity.CustName = txtCustName.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustFullName.Text.Trim()) == false)
            {
                entity.CustFullName = txtCustFullName.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustTypeID.Text.Trim()) == false)
            {
                entity.CustTypeID = int.Parse(txtCustTypeID.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustRelationID.Text.Trim()) == false)
            {
                entity.CustRelationID = int.Parse(txtCustRelationID.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustIndustryID.Text.Trim()) == false)
            {
                entity.CustIndustryID = int.Parse(txtCustIndustryID.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustEmpNumID.Text.Trim()) == false)
            {
                entity.CustEmpNumID = int.Parse(txtCustEmpNumID.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustInfo.Text.Trim()) == false)
            {
                entity.CustInfo = txtCustInfo.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustCountryID.Text.Trim()) == false)
            {
                entity.CustCountryID = int.Parse(txtCustCountryID.Text.Trim());
            }
            //只有选择了其他,才用textbox的值
            if (ddlProvince.Text == "其他")
            {
                if (string.IsNullOrEmpty(txtCustProvince.Text.Trim()) == false)
                {
                    entity.CustProvince = txtCustProvince.Text.Trim();
                }
            }
            else
            {
                entity.CustProvince = ddlProvince.Text;
            }

            if (string.IsNullOrEmpty(txtCustCity.Text.Trim()) == false)
            {
                entity.CustCity = txtCustCity.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustDistinct.Text.Trim()) == false)
            {
                entity.CustDistinct = txtCustDistinct.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustAddress.Text.Trim()) == false)
            {
                entity.CustAddress = txtCustAddress.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustTel.Text.Trim()) == false)
            {
                entity.CustTel = txtCustTel.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustFax.Text.Trim()) == false)
            {
                entity.CustFax = txtCustFax.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustWeb.Text.Trim()) == false)
            {
                entity.CustWeb = txtCustWeb.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustEmail.Text.Trim()) == false)
            {
                entity.CustEmail = txtCustEmail.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtCustCDate.Text.Trim()) == false)
            {
                entity.CustCDate = DateTime.Parse(txtCustCDate.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustCUserID.Value.Trim()) == false)
            {
                entity.CustCUserID = int.Parse(txtCustCUserID.Value.Trim());
            }
            if (string.IsNullOrEmpty(txtCustOwnerID.Text.Trim()) == false)
            {
                entity.CustOwnerID = int.Parse(txtCustOwnerID.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtSYSID.Text.Trim()) == false)
            {
                entity.SYSID = int.Parse(txtSYSID.Text.Trim());
            }

            if (string.IsNullOrEmpty(txtArrivalPort.Text.Trim()) == false)
            {
                entity.CustPort = txtArrivalPort.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtPayMethod.Text.Trim()) == false)
            {
                entity.CustPayMethod = txtPayMethod.Text;
            }
            if (string.IsNullOrEmpty(txtPurchaseChannels.Text.Trim()) == false)
            {
                entity.CustPurchaseChannels = txtPurchaseChannels.Text;
            }
            if (string.IsNullOrEmpty(txtSaleChannels.Text.Trim()) == false)
            {
                entity.CustSaleChannels = txtSaleChannels.Text;
            }
            if (string.IsNullOrEmpty(txtMaterial.Text.Trim()) == false)
            {
                entity.CustMaterial = txtMaterial.Text;
            }

            entity.CustModifyDate   = DateTime.Now;
            entity.CustModifyUserID = base.LoginUserID;
            //entity.CustBidPrice = txtBidPrice.Text;
            double cf = 0.0;

            double.TryParse(txtCommissionFactor.Text, out cf);
            entity.CommissionFactor = cf;
            entity.CustProduct      = txtCustProduct.Text;
            entity.IsActive         = true;
            //??还没想好Status字段用途,P,A,还是审批流程步骤1,2,3,4
            entity.Status = "A";

            //Ticket Fields
            if (string.IsNullOrEmpty(ddlGender.Text) == false)
            {
                entity.Gender = ddlGender.SelectedValue;
            }
            if (string.IsNullOrEmpty(txtBirthday.Text) == false)
            {
                entity.BirthDay = Convert.ToDateTime(txtBirthday.Text);
            }

            if (string.IsNullOrEmpty(ddlPreferPrice.Text) == false)
            {
                entity.PreferPrice = ddlPreferPrice.Text;
            }
            if (string.IsNullOrEmpty(ddlUseOwnMoney.Text) == false)
            {
                entity.UseOwnMoney = Convert.ToBoolean(ddlUseOwnMoney.Text);
            }
            if (string.IsNullOrEmpty(ddlRequireVisa.Text) == false)
            {
                entity.RequireVisa = Convert.ToBoolean(ddlRequireVisa.Text);
            }
            if (string.IsNullOrEmpty(txtFavoriteDest.Text) == false)
            {
                entity.FavoriteDest = txtFavoriteDest.Text;
            }
            if (string.IsNullOrEmpty(txtFavoriteProd.Text) == false)
            {
                entity.FavoriteProd = txtFavoriteProd.Text;
            }
            if (string.IsNullOrEmpty(txtPreferPlace.Text) == false)
            {
                entity.PreferPlace = txtPreferPlace.Text;
            }
            if (string.IsNullOrEmpty(txtBudget.Text) == false)
            {
                entity.Budget = txtBudget.Text;
            }
            if (string.IsNullOrEmpty(txtPosition.Text) == false)
            {
                entity.Position = txtPosition.Text;
            }
            if (string.IsNullOrEmpty(txtParentCompany.Text) == false)
            {
                entity.ParentCompany = txtParentCompany.Text;
            }
            if (string.IsNullOrEmpty(txtPassport.Text) == false)
            {
                entity.Passport = txtPassport.Text;
            }
            if (string.IsNullOrEmpty(txtPassportExpiryDate.Text) == false)
            {
                entity.PassportExpiryDate = txtPassportExpiryDate.Text;
            }

            if (string.IsNullOrEmpty(chkTravelDay.Text) == false)
            {
                entity.TravelDay = chkTravelDay.GetChecked(",");
            }

            entity.BuddyList = BuddyList1.strBuddyList;
            return(entity);
        }
Ejemplo n.º 18
0
        //获取输入数据
        private CRMCustomer GetNewCustomer(string CustName, long? CustOwnerID)
        {
            var entity = new CRMCustomer();
            entity.CustName = CustName.Trim();
            entity.CustFullName = CustName.Trim();
            entity.CustTypeID = 3;
            entity.CustRelationID = 6;
            entity.CustIndustryID = 1;
            //entity.CustEmpNumID = 1;
            //entity.CustCountryID = 37; //china
            entity.CustCDate = DateTime.Now;
            entity.CustCUserID = base.LoginUserID;
            if(CustOwnerID==null)
                entity.CustOwnerID = 0;
            else
                entity.CustOwnerID = (long)CustOwnerID;
            entity.SYSID = 1;
            entity.CustModifyDate = DateTime.Now;
            entity.CustModifyUserID = base.LoginUserID;
            entity.CommissionFactor = 1.0;
            entity.IsActive = true;
            entity.Status = "A";

            //Ticket Fields
            if (CustName.Contains(" MRS"))
                entity.Gender = "F";
            else
                entity.Gender = "M";

            return entity;
        }