Пример #1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.ProjectTask_BusinessScale model)
 {
     return(Dal.ProjectTask_BusinessScale.Instance.Update(model));
 }
        /// <summary>
        /// 将excel中信息同步到ProjectTask_Cust
        /// </summary>
        public void SyncInfoFromExcel(Entities.ProjectTaskInfo task)
        {
            if (task.Source == 1 && BLL.ProjectTask_Cust.Instance.Exists(task.PTID) == false)
            {
                int i = -1;
                if (int.TryParse(task.RelationID, out i) == false)
                {
                    return;
                }
                Entities.ExcelCustInfo excelInfo = BLL.ExcelCustInfo.Instance.GetExcelCustInfo(i);
                if (excelInfo == null)
                {
                    return;
                }
                //插入基本信息
                Entities.ProjectTask_Cust c = new Entities.ProjectTask_Cust();
                c.PTID     = task.PTID;
                c.CustName = excelInfo.CustName;

                BitAuto.YanFa.Crm2009.Entities.EnumCustomType?ct = this.GetCustTypeByName(excelInfo.TypeName);
                c.TypeID = ct.HasValue ? ((int)ct.Value).ToString() : "";

                //Crm2009.Entities.EnumCustomIndustry? ci = this.GetCustIndustryByName(excelInfo.IndustryName);
                //c.IndustryID = ci.HasValue ? ((int)ci.Value).ToString() : "";

                c.ProvinceID = BLL.AreaHelper.Instance.GetAreaIDByName(excelInfo.ProvinceName);
                c.CityID     = BLL.AreaHelper.Instance.GetAreaIDByName(excelInfo.CityName);
                c.CountyID   = BLL.AreaHelper.Instance.GetAreaIDByName(excelInfo.CountyName);
                c.BrandIDs   = BLL.CarBrandHelper.Instance.GetCarBrandIDsByNames(excelInfo.BrandName);
                c.Address    = excelInfo.Address;
                c.OfficeTel  = excelInfo.OfficeTel;
                c.Fax        = excelInfo.Fax;
                c.Zipcode    = excelInfo.Zipcode;

                c.CreateTime   = c.LastUpdateTime = DateTime.Now;
                c.CreateUserID = c.LastUpdateUserID = BLL.Util.GetLoginUserID();
                c.CarType      = excelInfo.CarType;
                c.ContactName  = excelInfo.ContactName;
                if (!string.IsNullOrEmpty(excelInfo.ContactName))
                {
                    c.ContactName = excelInfo.ContactName;
                }
                if (excelInfo.TradeMarketID > 0)
                {
                    c.TradeMarketID = excelInfo.TradeMarketID.ToString();
                }
                if (excelInfo.CarType > 0)
                {
                    c.CarType = excelInfo.CarType;
                }
                if (!string.IsNullOrEmpty(excelInfo.TypeName))
                {
                    foreach (BitAuto.YanFa.Crm2009.Entities.EnumCustomType type in (BitAuto.YanFa.Crm2009.Entities.EnumCustomType[])Enum.GetValues(typeof(BitAuto.YanFa.Crm2009.Entities.EnumCustomType)))
                    {
                        if (Utils.EnumHelper.GetEnumTextValue(type) == excelInfo.TypeName)
                        {
                            c.TypeID = ((int)type).ToString();
                            break;
                        }
                    }
                }
                if (excelInfo.MonthSales > 0 || excelInfo.MonthStock > 0 || excelInfo.MonthTrade > 0)
                {
                    Entities.ProjectTask_BusinessScale scaleInfo = new Entities.ProjectTask_BusinessScale();
                    scaleInfo.CreateTime   = DateTime.Now;
                    scaleInfo.CreateUserID = Util.GetLoginUserID();
                    scaleInfo.MonthSales   = excelInfo.MonthSales;
                    scaleInfo.MonthStock   = excelInfo.MonthStock;
                    scaleInfo.MonthTrade   = excelInfo.MonthTrade;
                    scaleInfo.Status       = 0;
                    scaleInfo.PTID         = task.PTID;
                    BLL.ProjectTask_BusinessScale.Instance.Insert(scaleInfo);
                }
                BLL.ProjectTask_Cust.Instance.Insert(c);
            }
        }