private void bindRelpaceCarData()
        {
            int _taskID;

            if (int.TryParse(TaskID, out _taskID))
            {
                Entities.OrderRelpaceCar model = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(_taskID);
                if (model != null)
                {
                    string carMaster = BLL.CarTypeAPI.Instance.GetMasterBrandNameByMasterBrandID(int.Parse(model.CarMasterID.ToString()));
                    string carSerial = BLL.CarTypeAPI.Instance.GetSerialNameBySerialID(int.Parse(model.CarSerialID.ToString()));
                    string carType   = BLL.CarTypeAPI.Instance.GetCarTypeNameByCarTypeID(int.Parse(model.CarTypeID.ToString()));
                    CarType = carMaster + "-" + carSerial + "-" + carType;

                    string carTypeNow   = BLL.CarTypeAPI.Instance.GetCarTypeNameByCarTypeID(int.Parse(model.RepCarTypeId.ToString()));
                    string carMasterNow = BLL.CarTypeAPI.Instance.GetMasterBrandNameByMasterBrandID(int.Parse(model.RepCarMasterID.ToString()));
                    string carSerialNow = BLL.CarTypeAPI.Instance.GetSerialNameBySerialID(int.Parse(model.RepCarSerialID.ToString()));
                    CarTypeNow = carMasterNow + "-" + carSerialNow + "-" + carTypeNow;

                    CarColorNow = model.ReplacementCarColor;
                    CarColor    = model.CarColor;
                    CarBuyTime  = model.ReplacementCarBuyYear.ToString() + "年" + model.ReplacementCarBuyMonth.ToString() + "月";
                    ReplacementCarLocationID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(model.RepCarProvinceID.ToString());
                    ReplacementCarUsedMiles  = model.ReplacementCarUsedMiles.ToString();
                    CarPrice = model.SalePrice.ToString();

                    //经销商iD
                    if (model.DealerID != Constant.INT_INVALID_VALUE)
                    {
                        if (int.TryParse(model.DealerID.ToString(), out DealerId))
                        {
                        }
                    }

                    DMSMemberName = model.DMSMemberName;
                    OrderRemark   = model.OrderRemark;
                    CreateTime    = model.OrderCreateTime.ToString();
                    CallRecord    = model.CallRecord;
                }
            }
        }
        internal void SubmitCheckInfo(bool isUpdate, out string msg)
        {
            msg = string.Empty;
            CheckInfo checkInfo = (CheckInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(CheckedInfoStr, typeof(CheckInfo));
            string    errorMsg  = string.Empty;

            if (!checkInfo.Validate(isUpdate, out errorMsg))
            {
                msg = "{Result:'no',CustID:'0',ErrorMsg:'" + errorMsg + "'}";
                return;
            }
            if (!string.IsNullOrEmpty(checkInfo.CustBaseInfo.TaskID))
            {
                //已购车
                if (checkInfo.CustBaseInfo.CustCategoryID == "2")
                {
                    Entities.OrderRelpaceCar info = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(Convert.ToInt32(checkInfo.CustBaseInfo.TaskID));

                    if (info == null)
                    {
                        msg = "{Result:'no',CustID:'0',ErrorMsg:'没找到客户信息'}";
                        return;
                    }
                    else
                    {
                        //记录更新之前的信息
                        StringBuilder sbUpdate = new StringBuilder();
                        sbUpdate.Append("修改客户【" + info.TaskID + "】:");
                        if (info.UserName != checkInfo.CustBaseInfo.CustName)
                        {
                            sbUpdate.Append("把姓名【" + info.UserName + "】修改为【" + checkInfo.CustBaseInfo.CustName + "】,");
                        }
                        if (info.UserGender != Convert.ToInt32(checkInfo.CustBaseInfo.Sex))
                        {
                            sbUpdate.Append("把性别" + info.UserGender == "1" ? "【男】" : "【女】" + "修改为" + checkInfo.CustBaseInfo == "1" ? "【男】" : "【女】" + ",");
                        }
                        if (info.AreaID != Convert.ToInt32(checkInfo.CustBaseInfo.AreaID))
                        {
                            sbUpdate.Append("把区域【" + BLL.Util.GetEnumOptText(typeof(Entities.EnumArea), (int)info.AreaID) + "】修改为【" + BLL.Util.GetEnumOptText(typeof(Entities.EnumArea), Convert.ToInt32(checkInfo.CustBaseInfo.AreaID)) + "】,");
                        }
                        if (info.ProvinceID != Convert.ToInt32(checkInfo.CustBaseInfo.ProvinceID))
                        {
                            sbUpdate.Append("把省【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(info.ProvinceID.ToString()) + "】修改为【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(checkInfo.CustBaseInfo.ProvinceID.ToString()) + "】,");
                        }
                        if (info.CityID != Convert.ToInt32(checkInfo.CustBaseInfo.CityID))
                        {
                            sbUpdate.Append("把市【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(info.CityID.ToString()) + "】修改为【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(checkInfo.CustBaseInfo.CityID.ToString()) + "】,");
                        }
                        if (info.CountyID != Convert.ToInt32(checkInfo.CustBaseInfo.CountyID))
                        {
                            sbUpdate.Append("把县【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(info.CountyID.ToString()) + "】修改为【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(checkInfo.CustBaseInfo.CountyID.ToString()) + "】,");
                        }
                        info.UserAddress = checkInfo.CustBaseInfo.Address;
                        info.AreaID      = Convert.ToInt32(checkInfo.CustBaseInfo.AreaID);
                        info.CityID      = Convert.ToInt32(checkInfo.CustBaseInfo.CityID);
                        info.CountyID    = Convert.ToInt32(checkInfo.CustBaseInfo.CountyID);
                        info.UserName    = checkInfo.CustBaseInfo.CustName;
                        info.ProvinceID  = Convert.ToInt32(checkInfo.CustBaseInfo.ProvinceID);
                        info.UserGender  = Convert.ToInt32(checkInfo.CustBaseInfo.Sex);
                        if (info.UserPhone != checkInfo.CustBaseInfo.UserPhone)
                        {
                            sbUpdate.Append("把电话【" + info.UserPhone + "】修改为【" + checkInfo.CustBaseInfo.UserPhone + "】,");
                        }
                        info.UserPhone = checkInfo.CustBaseInfo.UserPhone;
                        if (info.UserMobile != checkInfo.CustBaseInfo.UserMobile)
                        {
                            sbUpdate.Append("把手机【" + info.UserMobile + "】修改为【" + checkInfo.CustBaseInfo.UserMobile + "】,");
                        }
                        info.UserMobile = checkInfo.CustBaseInfo.UserMobile;
                        if (info.UserMail != checkInfo.CustBaseInfo.Email)
                        {
                            sbUpdate.Append("把邮箱【" + info.UserMail + "】修改为【" + checkInfo.CustBaseInfo.Email + "】,");
                        }
                        info.UserMail = checkInfo.CustBaseInfo.Email;
                        BLL.OrderRelpaceCar.Instance.Update(info);

                        //插入日志记录
                        BLL.Util.InsertUserLog(sbUpdate.ToString());
                    }
                }
                //未购车
                else
                {
                    Entities.OrderNewCar info = BLL.OrderNewCar.Instance.GetOrderNewCar(Convert.ToInt32(checkInfo.CustBaseInfo.TaskID));
                    if (info == null)
                    {
                        msg = "{Result:'no',CustID:'0',ErrorMsg:'没找到客户信息'}";
                        return;
                    }
                    else
                    {
                        //记录更新之前的信息
                        StringBuilder sbUpdate = new StringBuilder();
                        sbUpdate.Append("修改客户【" + info.TaskID + "】:");
                        if (info.UserName != checkInfo.CustBaseInfo.CustName)
                        {
                            sbUpdate.Append("把姓名【" + info.UserName + "】修改为【" + checkInfo.CustBaseInfo.CustName + "】,");
                        }
                        if (info.UserGender != Convert.ToInt32(checkInfo.CustBaseInfo.Sex))
                        {
                            sbUpdate.Append("把性别" + info.UserGender == "1" ? "【男】" : "【女】" + "修改为" + checkInfo.CustBaseInfo == "1" ? "【男】" : "【女】" + ",");
                        }
                        if (info.AreaID != Convert.ToInt32(checkInfo.CustBaseInfo.AreaID))
                        {
                            sbUpdate.Append("把区域【" + BLL.Util.GetEnumOptText(typeof(Entities.EnumArea), (int)info.AreaID) + "】修改为【" + BLL.Util.GetEnumOptText(typeof(Entities.EnumArea), Convert.ToInt32(checkInfo.CustBaseInfo.AreaID)) + "】,");
                        }
                        if (info.ProvinceID != Convert.ToInt32(checkInfo.CustBaseInfo.ProvinceID))
                        {
                            sbUpdate.Append("把省【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(info.ProvinceID.ToString()) + "】修改为【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(checkInfo.CustBaseInfo.ProvinceID.ToString()) + "】,");
                        }
                        if (info.CityID != Convert.ToInt32(checkInfo.CustBaseInfo.CityID))
                        {
                            sbUpdate.Append("把市【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(info.CityID.ToString()) + "】修改为【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(checkInfo.CustBaseInfo.CityID.ToString()) + "】,");
                        }
                        if (info.CountyID != Convert.ToInt32(checkInfo.CustBaseInfo.CountyID))
                        {
                            sbUpdate.Append("把县【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(info.CountyID.ToString()) + "】修改为【" + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(checkInfo.CustBaseInfo.CountyID.ToString()) + "】,");
                        }
                        info.UserAddress = checkInfo.CustBaseInfo.Address;
                        info.AreaID      = Convert.ToInt32(checkInfo.CustBaseInfo.AreaID);
                        info.CityID      = Convert.ToInt32(checkInfo.CustBaseInfo.CityID);
                        info.CountyID    = Convert.ToInt32(checkInfo.CustBaseInfo.CountyID);
                        info.UserName    = checkInfo.CustBaseInfo.CustName;
                        info.ProvinceID  = Convert.ToInt32(checkInfo.CustBaseInfo.ProvinceID);
                        info.UserGender  = Convert.ToInt32(checkInfo.CustBaseInfo.Sex);
                        if (info.UserPhone != checkInfo.CustBaseInfo.UserPhone)
                        {
                            sbUpdate.Append("把电话【" + info.UserPhone + "】修改为【" + checkInfo.CustBaseInfo.UserPhone + "】,");
                        }
                        info.UserPhone = checkInfo.CustBaseInfo.UserPhone;
                        if (info.UserMobile != checkInfo.CustBaseInfo.UserMobile)
                        {
                            sbUpdate.Append("把手机【" + info.UserMobile + "】修改为【" + checkInfo.CustBaseInfo.UserMobile + "】,");
                        }
                        info.UserMobile = checkInfo.CustBaseInfo.UserMobile;
                        if (info.UserMail != checkInfo.CustBaseInfo.Email)
                        {
                            sbUpdate.Append("把邮箱【" + info.UserMail + "】修改为【" + checkInfo.CustBaseInfo.Email + "】,");
                        }
                        info.UserMail = checkInfo.CustBaseInfo.Email;
                        BLL.OrderNewCar.Instance.Update(info);

                        //插入日志记录
                        BLL.Util.InsertUserLog(sbUpdate.ToString());
                    }
                }
                msg = "{Result:'yes',CustID:'',ErrorMsg:'" + errorMsg + "'}";
            }
        }
        private void CustBaseInfoBind()
        {
            if (!string.IsNullOrEmpty(RequstTaskID))
            {
                //判断数据来源
                Entities.OrderTask model = BLL.OrderTask.Instance.GetOrderTask(Convert.ToInt32(RequstTaskID));
                if (model != null)
                {
                    //未购车,试驾
                    if (model.Source == 1 || model.Source == 3)
                    {
                        Entities.OrderNewCar custBasicInfo = BLL.OrderNewCar.Instance.GetOrderNewCar(Convert.ToInt32(RequstTaskID));
                        if (custBasicInfo != null)
                        {
                            CustName = custBasicInfo.UserName;
                            if (custBasicInfo.UserGender == 1)
                            {
                                Sex = "先生";
                            }
                            else if (custBasicInfo.UserGender == 2)
                            {
                                Sex = "女士";
                            }
                            Address = custBasicInfo.UserAddress;
                            if (custBasicInfo.ProvinceID != Entities.Constants.Constant.INT_INVALID_VALUE)
                            {
                                PlaceStr += BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(custBasicInfo.ProvinceID.ToString());
                            }
                            if (custBasicInfo.CityID != Entities.Constants.Constant.INT_INVALID_VALUE)
                            {
                                PlaceStr += "," + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(custBasicInfo.CityID.ToString());
                            }
                            if (custBasicInfo.CountyID != Entities.Constants.Constant.INT_INVALID_VALUE)
                            {
                                PlaceStr += "," + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(custBasicInfo.CountyID.ToString());
                            }
                            AreaStr         = BLL.Util.GetEnumOptText(typeof(Entities.EnumArea), (int)custBasicInfo.AreaID);
                            CustCategoryStr = "未购车";
                            if (!string.IsNullOrEmpty(custBasicInfo.UserMobile) && !string.IsNullOrEmpty(custBasicInfo.UserPhone))
                            {
                                Tels = custBasicInfo.UserPhone + "," + custBasicInfo.UserMobile;
                            }
                            else if (!string.IsNullOrEmpty(custBasicInfo.UserMobile))
                            {
                                Tels = custBasicInfo.UserMobile;
                            }
                            else
                            {
                                Tels = custBasicInfo.UserPhone;
                            }


                            Email = custBasicInfo.UserMail;
                        }
                    }
                    //已购车
                    else
                    {
                        Entities.OrderRelpaceCar custBasicInfo = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(Convert.ToInt32(RequstTaskID));
                        if (custBasicInfo != null)
                        {
                            CustName = custBasicInfo.UserName;
                            if (custBasicInfo.UserGender == 1)
                            {
                                Sex = "先生";
                            }
                            else if (custBasicInfo.UserGender == 2)
                            {
                                Sex = "女士";
                            }
                            Address = custBasicInfo.UserAddress;
                            if (custBasicInfo.ProvinceID != Entities.Constants.Constant.INT_INVALID_VALUE)
                            {
                                PlaceStr += BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(custBasicInfo.ProvinceID.ToString());
                            }
                            if (custBasicInfo.CityID != Entities.Constants.Constant.INT_INVALID_VALUE)
                            {
                                PlaceStr += "," + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(custBasicInfo.CityID.ToString());
                            }
                            if (custBasicInfo.CountyID != Entities.Constants.Constant.INT_INVALID_VALUE)
                            {
                                PlaceStr += "," + BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaName(custBasicInfo.CountyID.ToString());
                            }
                            AreaStr         = BLL.Util.GetEnumOptText(typeof(Entities.EnumArea), (int)custBasicInfo.AreaID);
                            CustCategoryStr = "已购车";
                            if (!string.IsNullOrEmpty(custBasicInfo.UserMobile) && !string.IsNullOrEmpty(custBasicInfo.UserPhone))
                            {
                                Tels = custBasicInfo.UserPhone + "," + custBasicInfo.UserMobile;
                            }
                            else if (!string.IsNullOrEmpty(custBasicInfo.UserMobile))
                            {
                                Tels = custBasicInfo.UserMobile;
                            }
                            else
                            {
                                Tels = custBasicInfo.UserPhone;
                            }
                            Email = custBasicInfo.UserMail;
                        }
                    }

                    ///更具已购车未购车表确定Type
                    Entities.OrderBuyCarInfo modelOrderbuyCar = null;
                    modelOrderbuyCar = BLL.OrderBuyCarInfo.Instance.GetOrderBuyCarInfo(Convert.ToInt32(RequstTaskID));
                    if (modelOrderbuyCar != null)
                    {
                        if (modelOrderbuyCar.Type == 2)
                        {
                            CustCategoryStr = "未购车";
                        }
                        else
                        {
                            CustCategoryStr = "已购车";
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(SqlTransaction sqltran, Entities.OrderRelpaceCar model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@TaskID",                  SqlDbType.BigInt,            8),
                new SqlParameter("@YPOrderID",               SqlDbType.Int,               4),
                new SqlParameter("@UserName",                SqlDbType.NVarChar,         64),
                new SqlParameter("@UserPhone",               SqlDbType.NVarChar,         64),
                new SqlParameter("@UserMobile",              SqlDbType.NVarChar,         64),
                new SqlParameter("@UserMail",                SqlDbType.NVarChar,         64),
                new SqlParameter("@UserGender",              SqlDbType.Int,               4),
                new SqlParameter("@ProvinceID",              SqlDbType.Int,               4),
                new SqlParameter("@CityID",                  SqlDbType.Int,               4),
                new SqlParameter("@CountyID",                SqlDbType.Int,               4),
                new SqlParameter("@AreaID",                  SqlDbType.Int,               4),
                new SqlParameter("@UserAddress",             SqlDbType.NVarChar,       1024),
                new SqlParameter("@OrderCreateTime",         SqlDbType.SmallDateTime),
                new SqlParameter("@OrderRemark",             SqlDbType.NVarChar,       1024),
                new SqlParameter("@CarMasterID",             SqlDbType.Int,               4),
                new SqlParameter("@CarSerialID",             SqlDbType.Int,               4),
                new SqlParameter("@CarTypeID",               SqlDbType.Int,               4),
                new SqlParameter("@CarPrice",                SqlDbType.Decimal,           9),
                new SqlParameter("@CarColor",                SqlDbType.NVarChar,         16),
                new SqlParameter("@RepCarMasterID",          SqlDbType.Int,               4),
                new SqlParameter("@RepCarSerialID",          SqlDbType.Int,               4),
                new SqlParameter("@RepCarTypeId",            SqlDbType.Int,               4),
                new SqlParameter("@ReplacementCarBuyYear",   SqlDbType.SmallInt,          2),
                new SqlParameter("@ReplacementCarBuyMonth",  SqlDbType.SmallInt,          2),
                new SqlParameter("@ReplacementCarColor",     SqlDbType.NVarChar,         16),
                new SqlParameter("@ReplacementCarUsedMiles", SqlDbType.Decimal,           9),
                new SqlParameter("@RepCarProvinceID",        SqlDbType.Int,               4),
                new SqlParameter("@RepCarCityID",            SqlDbType.Int,               4),
                new SqlParameter("@RepCarCountyID",          SqlDbType.Int,               4),
                new SqlParameter("@DMSMemberCode",           SqlDbType.VarChar,          50),
                new SqlParameter("@DMSMemberName",           SqlDbType.NVarChar,        256),
                new SqlParameter("@CallRecord",              SqlDbType.NVarChar,       2000),
                new SqlParameter("@Status",                  SqlDbType.Int,               4),
                new SqlParameter("@CreateTime",              SqlDbType.DateTime),
                new SqlParameter("@SalePrice",               SqlDbType.Decimal, 9)
            };
            parameters[0].Value  = model.TaskID;
            parameters[1].Value  = model.YPOrderID;
            parameters[2].Value  = model.UserName;
            parameters[3].Value  = model.UserPhone;
            parameters[4].Value  = model.UserMobile;
            parameters[5].Value  = model.UserMail;
            parameters[6].Value  = model.UserGender;
            parameters[7].Value  = model.ProvinceID;
            parameters[8].Value  = model.CityID;
            parameters[9].Value  = model.CountyID;
            parameters[10].Value = model.AreaID;
            parameters[11].Value = model.UserAddress;
            parameters[12].Value = model.OrderCreateTime;
            parameters[13].Value = model.OrderRemark;
            parameters[14].Value = model.CarMasterID;
            parameters[15].Value = model.CarSerialID;
            parameters[16].Value = model.CarTypeID;
            parameters[17].Value = model.CarPrice;
            parameters[18].Value = model.CarColor;
            parameters[19].Value = model.RepCarMasterID;
            parameters[20].Value = model.RepCarSerialID;
            parameters[21].Value = model.RepCarTypeId;
            parameters[22].Value = model.ReplacementCarBuyYear;
            parameters[23].Value = model.ReplacementCarBuyMonth;
            parameters[24].Value = model.ReplacementCarColor;
            parameters[25].Value = model.ReplacementCarUsedMiles;
            parameters[26].Value = model.RepCarProvinceID;
            parameters[27].Value = model.RepCarCityID;
            parameters[28].Value = model.RepCarCountyID;
            parameters[29].Value = model.DMSMemberCode;
            parameters[30].Value = model.DMSMemberName;
            parameters[31].Value = model.CallRecord;
            parameters[32].Value = model.Status;
            parameters[33].Value = model.CreateTime;
            parameters[34].Value = model.SalePrice;

            return(SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_ORDERRELPACECAR_UPDATE, parameters));
        }
Exemplo n.º 5
0
        private Entities.OrderRelpaceCar LoadSingleOrderRelpaceCar(DataRow row)
        {
            Entities.OrderRelpaceCar model = new Entities.OrderRelpaceCar();

            if (row["TaskID"].ToString() != "")
            {
                model.TaskID = long.Parse(row["TaskID"].ToString());
            }
            if (row["YPOrderID"].ToString() != "")
            {
                model.YPOrderID = int.Parse(row["YPOrderID"].ToString());
            }
            model.UserName   = row["UserName"].ToString();
            model.UserPhone  = row["UserPhone"].ToString();
            model.UserMobile = row["UserMobile"].ToString();
            model.UserMail   = row["UserMail"].ToString();
            if (row["UserGender"].ToString() != "")
            {
                model.UserGender = int.Parse(row["UserGender"].ToString());
            }
            if (row["ProvinceID"].ToString() != "")
            {
                model.ProvinceID = int.Parse(row["ProvinceID"].ToString());
            }
            if (row["CityID"].ToString() != "")
            {
                model.CityID = int.Parse(row["CityID"].ToString());
            }
            if (row["CountyID"].ToString() != "")
            {
                model.CountyID = int.Parse(row["CountyID"].ToString());
            }
            if (row["AreaID"].ToString() != "")
            {
                model.AreaID = int.Parse(row["AreaID"].ToString());
            }
            model.UserAddress = row["UserAddress"].ToString();
            if (row["OrderCreateTime"].ToString() != "")
            {
                model.OrderCreateTime = DateTime.Parse(row["OrderCreateTime"].ToString());
            }
            model.OrderRemark = row["OrderRemark"].ToString();
            if (row["CarMasterID"].ToString() != "")
            {
                model.CarMasterID = int.Parse(row["CarMasterID"].ToString());
            }
            if (row["CarSerialID"].ToString() != "")
            {
                model.CarSerialID = int.Parse(row["CarSerialID"].ToString());
            }
            if (row["CarTypeID"].ToString() != "")
            {
                model.CarTypeID = int.Parse(row["CarTypeID"].ToString());
            }
            if (row["CarPrice"].ToString() != "")
            {
                model.CarPrice = decimal.Parse(row["CarPrice"].ToString());
            }
            model.CarColor = row["CarColor"].ToString();
            if (row["RepCarMasterID"].ToString() != "")
            {
                model.RepCarMasterID = int.Parse(row["RepCarMasterID"].ToString());
            }
            if (row["RepCarSerialID"].ToString() != "")
            {
                model.RepCarSerialID = int.Parse(row["RepCarSerialID"].ToString());
            }
            if (row["RepCarTypeId"].ToString() != "")
            {
                model.RepCarTypeId = int.Parse(row["RepCarTypeId"].ToString());
            }
            if (row["ReplacementCarBuyYear"].ToString() != "")
            {
                model.ReplacementCarBuyYear = int.Parse(row["ReplacementCarBuyYear"].ToString());
            }
            if (row["ReplacementCarBuyMonth"].ToString() != "")
            {
                model.ReplacementCarBuyMonth = int.Parse(row["ReplacementCarBuyMonth"].ToString());
            }
            model.ReplacementCarColor = row["ReplacementCarColor"].ToString();
            if (row["ReplacementCarUsedMiles"].ToString() != "")
            {
                model.ReplacementCarUsedMiles = decimal.Parse(row["ReplacementCarUsedMiles"].ToString());
            }
            if (row["SalePrice"].ToString() != "")
            {
                model.SalePrice = decimal.Parse(row["SalePrice"].ToString());
            }
            if (row["RepCarProvinceID"].ToString() != "")
            {
                model.RepCarProvinceID = int.Parse(row["RepCarProvinceID"].ToString());
            }
            if (row["RepCarCityID"].ToString() != "")
            {
                model.RepCarCityID = int.Parse(row["RepCarCityID"].ToString());
            }
            if (row["RepCarCountyID"].ToString() != "")
            {
                model.RepCarCountyID = int.Parse(row["RepCarCountyID"].ToString());
            }
            model.DMSMemberCode = row["DMSMemberCode"].ToString();
            model.DMSMemberName = row["DMSMemberName"].ToString();
            model.CallRecord    = row["CallRecord"].ToString();
            if (row["Status"].ToString() != "")
            {
                model.Status = int.Parse(row["Status"].ToString());
            }
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["DealerID"].ToString() != "")
            {
                model.DealerID = int.Parse(row["DealerID"].ToString());
            }
            return(model);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ddlAreaBind();
         //ddlDataSourceBind();
         if (!string.IsNullOrEmpty(RequstTaskID))
         {
             //判断数据来源
             Entities.OrderTask model = BLL.OrderTask.Instance.GetOrderTask(Convert.ToInt32(RequstTaskID));
             if (model != null)
             {
                 //未购车,试驾
                 if (model.Source == 1 || model.Source == 3)
                 {
                     this.rdoNoCar.Checked = true;
                     Entities.OrderNewCar custBasicInfo = BLL.OrderNewCar.Instance.GetOrderNewCar(Convert.ToInt32(RequstTaskID));
                     if (custBasicInfo != null)
                     {
                         this.txtCustName.Value = custBasicInfo.UserName;
                         this.txtAddress.Value  = custBasicInfo.UserAddress;
                         ProvinceID             = custBasicInfo.ProvinceID.ToString();
                         CityID   = custBasicInfo.CityID.ToString();
                         CountyID = custBasicInfo.CountyID.ToString();
                         //ddlDataSource.Value = "易湃";
                         if (custBasicInfo.UserGender == 1)
                         {
                             rdoMan.Checked = true;
                         }
                         else
                         {
                             rdoWomen.Checked = true;
                         }
                         ddlArea.Value  = custBasicInfo.AreaID.ToString();
                         txtTel1.Value  = custBasicInfo.UserPhone;
                         txtTel2.Value  = custBasicInfo.UserMobile;
                         txtEmail.Value = custBasicInfo.UserMail;
                     }
                 }
                 //已购车
                 else
                 {
                     this.rdoHavCar.Checked = true;
                     Entities.OrderRelpaceCar custBasicInfo = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(Convert.ToInt32(RequstTaskID));
                     if (custBasicInfo != null)
                     {
                         this.txtCustName.Value = custBasicInfo.UserName;
                         this.txtAddress.Value  = custBasicInfo.UserAddress;
                         ProvinceID             = custBasicInfo.ProvinceID.ToString();
                         CityID   = custBasicInfo.CityID.ToString();
                         CountyID = custBasicInfo.CountyID.ToString();
                         //ddlDataSource.Value = "易湃";
                         if (custBasicInfo.UserGender == 1)
                         {
                             rdoMan.Checked = true;
                         }
                         else
                         {
                             rdoWomen.Checked = true;
                         }
                         ddlArea.Value  = custBasicInfo.AreaID.ToString();
                         txtTel1.Value  = custBasicInfo.UserPhone;
                         txtTel2.Value  = custBasicInfo.UserMobile;
                         txtEmail.Value = custBasicInfo.UserMail;
                     }
                 }
                 ///更具已购车未购车表确定Type
                 Entities.OrderBuyCarInfo modelOrderbuyCar = null;
                 modelOrderbuyCar = BLL.OrderBuyCarInfo.Instance.GetOrderBuyCarInfo(Convert.ToInt32(RequstTaskID));
                 if (modelOrderbuyCar != null)
                 {
                     if (modelOrderbuyCar.Type == 2)
                     {
                         this.rdoNoCar.Checked  = true;
                         this.rdoHavCar.Checked = false;
                     }
                     else
                     {
                         this.rdoHavCar.Checked = true;
                         this.rdoNoCar.Checked  = false;
                     }
                 }
             }
         }
     }
 }
        private void GetBuyCarModel(string TaskID)
        {
            if (!string.IsNullOrEmpty(TaskID))
            {
                long _taskID = Convert.ToInt32(TaskID);
                //数据来源
                Entities.OrderTask model = BLL.OrderTask.Instance.GetOrderTask(_taskID);
                if (model != null)
                {
                    Type = model.Source.ToString();
                }

                BuyCarInfoModel = BLL.OrderBuyCarInfo.Instance.GetOrderBuyCarInfo(_taskID);
                if (BuyCarInfoModel != null)
                {
                    //汽车品牌
                    CarBrandID = Convert.ToInt32(BuyCarInfoModel.CarBrandId);
                    //汽车系列
                    CarSerialID = Convert.ToInt32(BuyCarInfoModel.CarSerialId);
                    CarTypeID   = Convert.ToInt32(BuyCarInfoModel.CarTypeID);
                }

                if (BuyCarInfoModel == null)
                {
                    BuyCarInfoModel = new Entities.OrderBuyCarInfo();
                }

                //1,3都从新车里取数据,modify by qizq 2013-7-19
                switch (model.Source)
                {
                case 1:
                    Entities.OrderNewCar model_newCar = new Entities.OrderNewCar();
                    model_newCar = BLL.OrderNewCar.Instance.GetOrderNewCar(_taskID);
                    if (model_newCar != null)
                    {
                        //易湃订单ID
                        YPOrderID = model_newCar.YPOrderID.ToString();
                    }
                    break;

                case 3:
                    Entities.OrderNewCar model_newCar1 = new Entities.OrderNewCar();
                    model_newCar1 = BLL.OrderNewCar.Instance.GetOrderNewCar(_taskID);
                    if (model_newCar1 != null)
                    {
                        //易湃订单ID
                        YPOrderID = model_newCar1.YPOrderID.ToString();
                    }
                    break;

                case 2:
                    Entities.OrderRelpaceCar model_relpaceCar = new Entities.OrderRelpaceCar();
                    model_relpaceCar = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(_taskID);
                    if (model_relpaceCar != null)
                    {
                        //易湃订单ID
                        YPOrderID = model_relpaceCar.YPOrderID.ToString();
                    }
                    break;
                }
            }
        }
        private void Submit(out string msg, int userID)
        {
            //此方法内的逻辑可参考文档:$/A5信息系统研发/销售业务管理平台/客户关系管理/doc/Call Center/无主订单处理页面保存和提交逻辑.docx  ---- Add By Chybin At 2013-07-19

            msg = "";

            //System.Threading.Thread.Sleep(5000);

            #region 准备数据

            NewCarConsultInfo              newInfo        = null;                       //新车订单信息
            ReplaceCarConsultInfo          replaceInfo    = null;                       //置换订单信息
            Entities.OrderTask             orderTaskModel = null;                       //无主订单任务信息
            Entities.OrderTaskOperationLog orderLog       = null;                       //任务操作日志
            List <StringBuilder>           listLogStr     = new List <StringBuilder>(); //用户操作日志
            StringBuilder sblogstr = new StringBuilder();
            string        logstr   = "";

            #region 取得新车/置换无主订单信息更新后Model(此时不保存到数据库)

            Entities.OrderNewCar     newModel     = null; //新车订单实体类
            Entities.OrderRelpaceCar replaceModel = null; //置换订单实体类

            if (Source == "1" || Source == "3")
            {
                newInfo = (NewCarConsultInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(NewCarConsultInfoStr, typeof(NewCarConsultInfo));

                newModel = OrderNewSave.Save(newInfo, out msg, userID, int.Parse(TaskID));
                if (msg != "")
                {
                    return;
                }
            }
            else if (Source == "2")
            {
                replaceInfo  = (ReplaceCarConsultInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ReplaceCarConsultInfoStr, typeof(ReplaceCarConsultInfo));
                replaceModel = OrderReplaceSave.Save(replaceInfo, out msg, userID, long.Parse(TaskID));
                if (msg != "")
                {
                    return;
                }
            }

            #endregion

            #region 取得任务的更新后信息

            orderTaskModel = BLL.OrderTask.Instance.GetOrderTask(long.Parse(TaskID));
            if (orderTaskModel == null)
            {
                msg += "没有找到相关的任务信息";
                return;
            }

            if (orderTaskModel.TaskStatus != 2 && orderTaskModel.TaskStatus != 3)
            {
                msg += "当前任务状态不能保存和提交";
                return;
            }

            if (orderTaskModel.AssignUserID != userID)
            {
                msg += "此订单没有分配给你";
                return;
            }


            //修改状态
            if (Action == "save")
            {
                orderTaskModel.TaskStatus = (int)TaskStatus.Processing;
            }
            else if (Action == "sub")
            {
                orderTaskModel.TaskStatus = (int)TaskStatus.Processed;
                orderTaskModel.SubmitTime = DateTime.Now;
            }

            //是否已选择经销商 只有在提交时,才会改动该属性 -是否已选择经销商 lxw
            if (Action == "sub")
            {
                if (((Source == "1" || Source == "3") && newModel.DMSMemberCode != "") || (Source == "2" && replaceModel.DMSMemberCode != ""))
                {
                    orderTaskModel.IsSelectDMSMember = true;
                }
                else
                {
                    orderTaskModel.IsSelectDMSMember = false;
                }
            }

            if (Source == "1" || Source == "3")
            {
                orderTaskModel.UserName = newModel.UserName;
            }
            else if (Source == "2")
            {
                orderTaskModel.UserName = replaceModel.UserName;
            }

            if (NoDealerReasonID != "")
            {
                orderTaskModel.NoDealerReasonID = int.Parse(NoDealerReasonID);
            }
            orderTaskModel.NoDealerReason = NoDealerReason;


            #endregion

            #region 任务操作日志

            orderLog = new OrderTaskOperationLog();

            //modify by qizq 2013-1-4首先判断是否是通话中
            if (IsCalling == "1")
            {
                if (HistoryLogID == "")
                {
                    //通话中提交把本地录音主键付给实体
                    long CallRecordReCID = 0;
                    if (CallRecordID != "")
                    {
                        if (long.TryParse(CallRecordID, out CallRecordReCID))
                        {
                            orderLog.CallRecordID = CallRecordReCID;
                        }
                    }
                }
            }
            //


            orderLog.TaskID = int.Parse(TaskID);

            if (Action == "save")
            {
                orderLog.OperationStatus = (int)OperationStatus.Save;
            }
            else if (Action == "sub")
            {
                orderLog.OperationStatus = (int)OperationStatus.Submit;
            }
            orderLog.TaskStatus   = orderTaskModel.TaskStatus;
            orderLog.CreateTime   = DateTime.Now;
            orderLog.CreateUserID = userID;

            #endregion

            #region 如果是提交操作,更新客户信息、插入咨询类型、添加客户联系记录

            Entities.CustBasicInfo          custmodel     = null;       //客户信息实体类
            Entities.CustTel                telPhoneMode  = null;       //电话实体类
            Entities.CustTel                telMobileMode = null;       //电话实体类
            Entities.CustEmail              emailMode     = null;       //邮件实体类
            Entities.ConsultOrderNewCar     cNewCar       = null;       //新车咨询类型
            Entities.ConsultOrderRelpaceCar cReplaceCar   = null;       //置换车咨询类型
            Entities.CustHistoryInfo        custHistInfo  = null;       //客户联系记录

            Entities.BuyCarInfo buyCarInfo = new Entities.BuyCarInfo(); //已购车或未购车信息 lxw

            if (Action == "sub")
            {
                #region 更新或插入客户信息
                //代码失效,功能废弃,需求重新实现
                #endregion

                #region 插入咨询类型

                if (Source == "1" || Source == "3")
                {
                    cNewCar = new ConsultOrderNewCar();

                    #region 赋值

                    cNewCar.CarBrandId   = newModel.CarMasterID;
                    cNewCar.CarSerialId  = newModel.CarSerialID;
                    cNewCar.CarNameID    = newModel.CarTypeID;
                    cNewCar.CarColor     = newModel.CarColor;
                    cNewCar.DealerCode   = newModel.DMSMemberCode;
                    cNewCar.DealerName   = newModel.DMSMemberName;
                    cNewCar.OrderRemark  = newModel.OrderRemark;
                    cNewCar.CallRecord   = newModel.CallRecord;
                    cNewCar.CreateTime   = DateTime.Now;
                    cNewCar.CreateUserID = userID;

                    #endregion
                }
                else if (Source == "2")
                {
                    cReplaceCar = new ConsultOrderRelpaceCar();

                    #region 赋值

                    cReplaceCar.WantBrandId        = replaceModel.RepCarMasterID;
                    cReplaceCar.WantSerialId       = replaceModel.RepCarSerialID;
                    cReplaceCar.WantNameID         = replaceModel.RepCarTypeId;
                    cReplaceCar.WantCarColor       = replaceModel.ReplacementCarColor;
                    cReplaceCar.WantDealerName     = replaceModel.DMSMemberName;
                    cReplaceCar.WantDealerCode     = replaceModel.DMSMemberCode;
                    cReplaceCar.CallRecord         = replaceModel.CallRecord;
                    cReplaceCar.OldBrandId         = replaceModel.CarMasterID;
                    cReplaceCar.OldSerialId        = replaceModel.CarSerialID;
                    cReplaceCar.OldNameID          = replaceModel.CarTypeID;
                    cReplaceCar.OldCarColor        = replaceModel.CarColor;
                    cReplaceCar.RegisterDateYear   = replaceModel.ReplacementCarBuyYear.ToString();
                    cReplaceCar.RegisterDateMonth  = replaceModel.ReplacementCarBuyMonth.ToString();
                    cReplaceCar.RegisterProvinceID = replaceModel.RepCarProvinceID;
                    cReplaceCar.RegisterCityID     = replaceModel.RepCarCityID;
                    cReplaceCar.RegisterCountyID   = replaceModel.RepCarCountyID;
                    cReplaceCar.Mileage            = (decimal)replaceModel.ReplacementCarUsedMiles;
                    cReplaceCar.PresellPrice       = replaceModel.SalePrice;
                    cReplaceCar.OrderRemark        = replaceModel.OrderRemark;
                    cReplaceCar.CreateTime         = DateTime.Now;
                    cReplaceCar.CreateUserID       = userID;

                    #endregion
                }

                #endregion

                #region 插入客户历史记录

                custHistInfo = new CustHistoryInfo();

                #region 赋值

                custHistInfo.TaskID = TaskID;
                if (Source == "1" || Source == "3")
                {
                    custHistInfo.ConsultID = 60010;//新车咨询类型
                }
                else
                {
                    custHistInfo.ConsultID = 60011;//置换咨询类型
                }
                custHistInfo.RecordType        = 2;
                custHistInfo.QuestionQuality   = (int)QuestionNature.NatureCommon;
                custHistInfo.ProcessStatus     = (int)EnumTaskStatus.TaskStatusOver;
                custHistInfo.CreateTime        = DateTime.Now;
                custHistInfo.CreateUserID      = userID;
                custHistInfo.LastTreatmentTime = DateTime.Now;

                #endregion

                #endregion
            }

            #endregion

            #endregion

            #region 事务提交

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction(IsolationLevel.ReadUncommitted, "SampleTransaction");

            try
            {
                #region 保存新车/置换无主订单信息

                if (Source == "1" || Source == "3")
                {
                    BLL.OrderNewCar.Instance.Update(tran, newModel);
                }
                else if (Source == "2")
                {
                    BLL.OrderRelpaceCar.Instance.Update(tran, replaceModel);
                }

                #endregion

                #region 修改任务信息

                BLL.OrderTask.Instance.Update(tran, orderTaskModel);

                #endregion

                #region 任务操作日志

                //modify by qizq 2013-1-4不是在通话中,处理记录已存在更新处理记录
                if (IsCalling != "1" && HistoryLogID != "")
                {
                    //通话中提交把本地录音主键付给实体
                    long CallRecordReCID = 0;
                    if (CallRecordID != "")
                    {
                        if (long.TryParse(CallRecordID, out CallRecordReCID))
                        {
                            orderLog.CallRecordID = CallRecordReCID;
                        }
                    }
                    long HistoryLogIDLog = 0;
                    if (long.TryParse(HistoryLogID, out HistoryLogIDLog))
                    {
                        orderLog.RecID = HistoryLogIDLog;
                    }
                    BLL.OrderTaskOperationLog.Instance.Update(tran, orderLog);
                }
                else
                {
                    BLL.OrderTaskOperationLog.Instance.Insert(tran, orderLog);
                }
                //



                #endregion

                if (Action == "sub")
                {
                    string retCustID = "";

                    #region 更新或插入客户信息

                    if (custmodel.RecID == -2)
                    {
                        //新加的客户

                        retCustID = BLL.CustBasicInfo.Instance.Insert(tran, custmodel);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了客户‘" + custmodel.CustName + "’的信息【ID:" + retCustID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑客户信息
                        BLL.CustBasicInfo.Instance.Update(tran, custmodel);
                        retCustID = custmodel.CustID;
                    }
                    #endregion

                    #region 插入电话

                    if (telPhoneMode != null)
                    {
                        telPhoneMode.CustID = retCustID;
                        BLL.CustTel.Instance.Insert(tran, telPhoneMode);
                    }

                    if (telMobileMode != null)
                    {
                        telMobileMode.CustID = retCustID;
                        BLL.CustTel.Instance.Insert(tran, telMobileMode);
                    }

                    #endregion

                    #region 插入邮箱

                    if (emailMode != null)
                    {
                        emailMode.CustID = retCustID;
                        BLL.CustEmail.Instance.Insert(tran, emailMode);
                    }

                    #endregion

                    #region 插入咨询类型

                    int retDataID = 0;

                    if (cNewCar != null)
                    {
                        cNewCar.CustID = retCustID;
                        retDataID      = BLL.ConsultOrderNewCar.Instance.Insert(tran, cNewCar);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了无主订单新车联系咨询记录【ID:" + retDataID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }
                    if (cReplaceCar != null)
                    {
                        cReplaceCar.CustID = retCustID;
                        retDataID          = BLL.ConsultOrderRelpaceCar.Instance.Insert(tran, cReplaceCar);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了无主订单置换联系咨询记录【ID:" + retDataID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    #endregion

                    #region 插入未购车或已购车记录 BuyCarInfo lxw

                    if (buyCarInfo != null && buyCarInfo.RecID == -2)
                    {
                        buyCarInfo.CustID = retCustID;
                        int recID = BLL.BuyCarInfo.Instance.Insert(tran, buyCarInfo);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了未购车已购车BuyCarInfo表的记录【ID:" + recID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    if (buyCarInfo != null && buyCarInfo.RecID != -2)
                    {
                        BLL.BuyCarInfo.Instance.Update(tran, buyCarInfo);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "修改了未购车已购车BuyCarInfo表的记录【ID:" + buyCarInfo.RecID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    #endregion

                    #region 插入客户联系记录

                    if (custHistInfo != null)
                    {
                        custHistInfo.CustID        = retCustID;
                        custHistInfo.ConsultDataID = retDataID;
                        BLL.CustHistoryInfo.Instance.Insert(tran, custHistInfo);
                    }

                    #endregion

                    #region 插入已购车或未购车信息

                    #endregion

                    #region 保存用户操作日志

                    foreach (StringBuilder sbStr in listLogStr)
                    {
                        BLL.Util.InsertUserLog(tran, sbStr.ToString());
                    }
                    #endregion
                }

                if (msg == "")
                {
                    tran.Commit();
                    if (Action == "sub")
                    {
                        #region 调用易湃接口,传回数据

                        string errorMsg    = "";
                        int    retService  = 0;
                        short  isSelectDMS = 0;

                        #region 调用接口

                        BitAuto.ISDC.CC2012.WebService.NoDealerOrderHelper OrderHelper = new BitAuto.ISDC.CC2012.WebService.NoDealerOrderHelper();
                        if (Source == "1")                                                    //新车
                        {
                            isSelectDMS = newModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetNewCarOrder(newModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }
                        else if (Source == "2")                                                   //置换
                        {
                            isSelectDMS = replaceModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetReplacementOrder(replaceModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }
                        else if (Source == "3")
                        {
                            isSelectDMS = newModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetTestDriveOrder(newModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }

                        #endregion

                        #region 插入更新无主订单数据日志表

                        Entities.UpdateOrderData updateDateMode = new UpdateOrderData();
                        updateDateMode.TaskID = TaskID;

                        if (Source == "1" || Source == "3")
                        {
                            updateDateMode.YPOrderID = newModel.YPOrderID;
                        }
                        else if (Source == "2")
                        {
                            updateDateMode.YPOrderID = replaceModel.YPOrderID;
                        }

                        updateDateMode.UpdateType = retService;
                        updateDateMode.IsUpdate   = retService; // 1 成功了,不用处理,-1 需要重新处理
                        if (retService == 1)
                        {
                            updateDateMode.UpdateDateTime = DateTime.Now;
                        }
                        updateDateMode.UpdateErrorMsg = errorMsg;
                        updateDateMode.CreateTime     = DateTime.Now;
                        updateDateMode.CreateUserID   = userID;
                        updateDateMode.APIType        = 1;

                        BLL.UpdateOrderData.Instance.Insert(updateDateMode);

                        #endregion

                        if (retService == -1)
                        {
                            msg = "InterfaceErr|" + errorMsg;
                        }

                        #endregion
                    }
                }
                else
                {
                    tran.Rollback();
                }
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }



            #endregion
        }
Exemplo n.º 9
0
        private void BindInfo()
        {
            #region 根据类型绑定联系记录控件
            //1新车,3试驾modify by qizq 2013-7-19
            if (Source == "1" || Source == "3")
            {
                //新车订单
                Entities.OrderNewCar newCarModel = BLL.OrderNewCar.Instance.GetOrderNewCar(long.Parse(TID));
                if (newCarModel != null)
                {
                    #region 绑定新车订单

                    this.ddlNewBrand  = newCarModel.CarMasterID.ToString();
                    this.ddlNewSerial = newCarModel.CarSerialID.ToString();
                    this.ddlNewName   = newCarModel.CarTypeID.ToString();
                    ///this.ddlNewCarColor.Value = newCarModel.CarColor;
                    this.ddlCarTypeID = newCarModel.CarTypeID.ToString();
                    nowColor          = newCarModel.CarColor;

                    //经销商
                    this.hidNewCarDMSmemberCode.Value = newCarModel.DMSMemberCode;
                    //名称
                    this.txtNewDealer.Value = newCarModel.DMSMemberName;

                    this.labNewsRemark.InnerText   = newCarModel.OrderRemark;
                    this.labNewCreatTime.InnerText = DateTime.Parse(newCarModel.OrderCreateTime.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                    this.txtNewCallRecord.Value    = newCarModel.CallRecord;
                    //经销商iD
                    if (newCarModel.DealerID != Constant.INT_INVALID_VALUE)
                    {
                        if (int.TryParse(newCarModel.DealerID.ToString(), out DealerId))
                        {
                        }
                    }
                    #region 隐藏域

                    this.hidDMSCode.Value = newCarModel.DMSMemberCode;
                    this.hidDMSName.Value = newCarModel.DMSMemberName;
                    //this.hidDMSLevel.Value = newCarModel.hidDMSLevel;
                    //this.hidDMSAddress.Value = newCarModel.hidDMSAddress;
                    //this.hidDMSTel.Value = newCarModel.hidDMSTel;
                    //this.hidDMSCity.Value = newCarModel.hidDMSCity;

                    #endregion

                    #endregion
                }
            }
            else if (Source == "2")
            {
                //置换订单
                Entities.OrderRelpaceCar replaceCarModel = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(long.Parse(TID));
                if (replaceCarModel != null)
                {
                    #region 绑定置换订单信息

                    this.ddlWantBrand    = replaceCarModel.CarMasterID.ToString();
                    this.ddlWantSerial   = replaceCarModel.CarSerialID.ToString();
                    this.ddlWantName     = replaceCarModel.CarTypeID.ToString();
                    this.ddlCarTypeID    = replaceCarModel.RepCarTypeId.ToString();
                    this.ddlRecCarTypeID = replaceCarModel.CarTypeID.ToString();
                    nowColor             = replaceCarModel.ReplacementCarColor;
                    relColor             = replaceCarModel.CarColor;

                    //经销商
                    this.hidWantDMSMemberCode.Value = replaceCarModel.DMSMemberCode;
                    // //名称
                    this.txtWantDealer.Value = replaceCarModel.DMSMemberName;

                    this.dllOldBrand  = replaceCarModel.RepCarMasterID.ToString();
                    this.dllOldSerial = replaceCarModel.RepCarSerialID.ToString();
                    this.dllOldName   = replaceCarModel.RepCarTypeId.ToString();

                    this.dllOldColor.Value     = replaceCarModel.ReplacementCarColor;
                    this.dllRegDateYear.Value  = replaceCarModel.ReplacementCarBuyYear.ToString();
                    this.dllRegDateMonth.Value = replaceCarModel.ReplacementCarBuyMonth.ToString();
                    //省份

                    Province = replaceCarModel.RepCarProvinceID.ToString();
                    City     = replaceCarModel.RepCarCityID.ToString();
                    County   = replaceCarModel.RepCarCountyID.ToString();

                    this.txtMileage.Value            = replaceCarModel.ReplacementCarUsedMiles.ToString();
                    this.txtProSellPrice.Value       = replaceCarModel.SalePrice.ToString();
                    this.labWantRemark.InnerText     = replaceCarModel.OrderRemark;
                    this.labWantCreateTime.InnerText = DateTime.Parse(replaceCarModel.OrderCreateTime.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                    this.txtReplaceCallRecord.Value  = replaceCarModel.CallRecord;

                    this.hidDMSCode.Value = replaceCarModel.DMSMemberCode;
                    this.hidDMSName.Value = replaceCarModel.DMSMemberName;

                    //经销商iD
                    if (replaceCarModel.DealerID != Constant.INT_INVALID_VALUE)
                    {
                        if (int.TryParse(replaceCarModel.DealerID.ToString(), out DealerId))
                        {
                        }
                    }

                    #endregion
                }
            }
            //根据经销商id,取名称
            if (DealerId != 0)
            {
                BitAuto.YanFa.Crm2009.Entities.DMSMember DMSModel = BitAuto.YanFa.Crm2009.BLL.DMSMember.Instance.GetDMSMemberByMemberCode(DealerId.ToString());
                if (DMSModel != null)
                {
                    DealerName = DMSModel.Name;
                    MemberID   = DMSModel.ID.ToString();
                    CustID     = DMSModel.CustID;
                }
            }

            #endregion
        }
Exemplo n.º 10
0
        /// <summary>
        /// 根据易湃置换订单实体信息,插入表OrderRelpaceCar信息
        /// </summary>
        /// <param name="tran"></param>
        /// <param name="taskID">任务ID</param>
        /// <param name="model">易湃置换订单实体信息</param>
        /// <returns></returns>
        public bool InsertByTaskID(SqlTransaction tran, long taskID, Entities.OrderRelpaceCarLog model)
        {
            Entities.OrderRelpaceCar orModel = new Entities.OrderRelpaceCar();
            orModel.TaskID     = taskID;
            orModel.YPOrderID  = model.YPOrderID;
            orModel.UserName   = model.UserName;
            orModel.UserPhone  = model.UserPhone;
            orModel.UserMobile = model.UserMobile;
            orModel.UserMail   = model.UserMail;
            if (model.UserGender != null && model.UserGender.Value == 0)
            {
                orModel.UserGender = 2;//性别“女”
            }
            else
            {
                orModel.UserGender = model.UserGender;
            }
            orModel.ProvinceID = null;
            orModel.CityID     = null;
            orModel.CountyID   = null;
            if (model.LocationID != null)
            {
                string locationName = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaStrByAreaID(model.LocationID.Value.ToString());
                switch (locationName.Split(',').Length)
                {
                case 1: orModel.ProvinceID = int.Parse(locationName.Split(',')[0]);
                    break;

                case 2:
                    orModel.ProvinceID = int.Parse(locationName.Split(',')[0]);
                    orModel.CityID     = int.Parse(locationName.Split(',')[1]);
                    break;

                case 3:
                    orModel.ProvinceID = int.Parse(locationName.Split(',')[0]);
                    orModel.CityID     = int.Parse(locationName.Split(',')[1]);
                    orModel.CountyID   = int.Parse(locationName.Split(',')[2]);
                    break;

                default:
                    break;
                }
            }
            orModel.AreaID          = null;
            orModel.UserAddress     = model.UserAddress;
            orModel.OrderCreateTime = model.OrderCreateTime;
            orModel.OrderRemark     = model.OrderRemark;
            orModel.CarMasterID     = null;
            orModel.CarSerialID     = null;
            orModel.CarTypeID       = null;
            if (model.CarID != null)
            {
                orModel.CarTypeID = model.CarID;
                int CarMasterID = 0;
                int CarSerialID = 0;
                int brandID     = 0;
                BLL.CarTypeAPI.Instance.GetSerialIDAndMasterBrandIDByCarTypeID(model.CarID.Value, out CarSerialID, out CarMasterID, out brandID);
                //orModel.CarMasterID = CarMasterID;
                //orModel.CarSerialID = CarSerialID;
                if (CarMasterID > 0)
                {
                    orModel.CarMasterID = CarMasterID;
                }
                if (CarSerialID > 0)
                {
                    orModel.CarSerialID = CarSerialID;
                }
            }
            orModel.CarPrice       = model.CarPrice;
            orModel.CarColor       = model.CarColor;
            orModel.RepCarMasterID = null;
            orModel.RepCarSerialID = null;
            orModel.RepCarTypeId   = null;
            if (model.ReplacementCarId != null)
            {
                orModel.RepCarTypeId = model.ReplacementCarId;
                int CarMasterID = 0;
                int CarSerialID = 0;
                int brandID     = 0;
                BLL.CarTypeAPI.Instance.GetSerialIDAndMasterBrandIDByCarTypeID(model.ReplacementCarId.Value, out CarSerialID, out CarMasterID, out brandID);
                //orModel.RepCarMasterID = CarMasterID;
                //orModel.RepCarSerialID = CarSerialID;
                if (CarMasterID > 0)
                {
                    orModel.RepCarMasterID = CarMasterID;
                }
                if (CarSerialID > 0)
                {
                    orModel.RepCarSerialID = CarSerialID;
                }
            }
            orModel.ReplacementCarBuyYear   = model.ReplacementCarBuyYear;
            orModel.ReplacementCarBuyMonth  = model.ReplacementCarBuyMonth;
            orModel.ReplacementCarColor     = model.ReplacementCarColor;
            orModel.ReplacementCarUsedMiles = model.ReplacementCarUsedMiles;

            orModel.SalePrice        = model.SalePrice;
            orModel.RepCarProvinceID = null;
            orModel.RepCarCityID     = null;
            orModel.RepCarCountyID   = null;
            if (model.ReplacementCarLocationID != null)
            {
                string locationName = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaStrByAreaID(model.ReplacementCarLocationID.Value.ToString());
                switch (locationName.Split(',').Length)
                {
                case 1: orModel.RepCarProvinceID = int.Parse(locationName.Split(',')[0]);
                    break;

                case 2:
                    orModel.RepCarProvinceID = int.Parse(locationName.Split(',')[0]);
                    orModel.RepCarCityID     = int.Parse(locationName.Split(',')[1]);
                    break;

                case 3:
                    orModel.RepCarProvinceID = int.Parse(locationName.Split(',')[0]);
                    orModel.RepCarCityID     = int.Parse(locationName.Split(',')[1]);
                    orModel.RepCarCountyID   = int.Parse(locationName.Split(',')[2]);
                    break;

                default:
                    break;
                }
            }
            orModel.DMSMemberCode = string.Empty;
            orModel.DMSMemberName = string.Empty;
            orModel.CallRecord    = string.Empty;
            orModel.Status        = 0;
            orModel.CreateTime    = DateTime.Now;
            orModel.DealerID      = model.DealerID;

            int recid = Insert(tran, orModel);

            if (recid > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SqlTransaction sqltran, Entities.OrderRelpaceCar model)
 {
     return(Dal.OrderRelpaceCar.Instance.Update(sqltran, model));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.OrderRelpaceCar model)
 {
     return(Dal.OrderRelpaceCar.Instance.Update(model));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Insert(Entities.OrderRelpaceCar model)
 {
     Dal.OrderRelpaceCar.Instance.Insert(model);
 }
        public static Entities.OrderRelpaceCar Save(ReplaceCarConsultInfo replaceInfo, out string msg, int userID, long tid)
        {
            msg = "";

            #region 检查

            if (replaceInfo == null)
            {
                msg += "置换车联系信息为空<br/>";
            }


            if (replaceInfo.CarMasterID == "0")
            {
                msg += "请选择意向车型的品牌<br/>";
            }
            if (replaceInfo.CarSerialID == "0")
            {
                msg += "请选择意向车型的系列<br/>";
            }
            if (replaceInfo.CarTypeID == "0")
            {
                msg += "请选择意向车型的车型<br/>";
            }
            //if (replaceInfo.CarColor == "")
            //{
            //    msg += "请选择意向车的颜色<br/>";
            //}
            if (replaceInfo.RepCarMasterID == "")
            {
                msg += "请选择现有车型的品牌<br/>";
            }
            if (replaceInfo.RepCarSerialID == "")
            {
                msg += "请选择现有车型的系列<br/>";
            }
            if (replaceInfo.RepCarTypeId == "")
            {
                msg += "请选择现有车型的车型<br/>";
            }
            //if (replaceInfo.ReplacementcCarColor == "")
            //{
            //    msg += "请选择现有车的颜色<br/>";
            //}
            if (replaceInfo.RepCarProvinceID == "-1")
            {
                msg += "请选择车牌所在地省份<br/>";
            }
            if (replaceInfo.RepCarCityID == "-1")
            {
                msg += "请选择车牌所在地城市<br/>";
            }
            //if (replaceInfo.RepCarCountyID == "-1")
            //{
            //    msg += "请选择车牌所在地区县<br/>";
            //}
            if (replaceInfo.ReplacementCarUsedMiles == "")
            {
                msg += "请填写已行驶里程<br/>";
            }
            decimal decVal = 0;
            if (!decimal.TryParse(replaceInfo.ReplacementCarUsedMiles, out decVal))
            {
                msg += "已行驶里程应该为数字<br/>";
            }
            if (replaceInfo.SellPrice == "")
            {
                msg += "请填写预售价格<br/>";
            }

            if (!decimal.TryParse(replaceInfo.SellPrice, out decVal))
            {
                msg += "预售价格应该为数字<br/>";
            }
            if (replaceInfo.CallRecord == "")
            {
                msg += "请填写电话记录<br/>";
            }

            if (replaceInfo.UserName == "")
            {
                msg += "请填写用户姓名<br/>";
            }

            decimal zdPrice = BLL.CarTypeAPI.Instance.GetCarReferPriceByCarTypeID(int.Parse(replaceInfo.RepCarTypeId));

            //                            (注意)这里 CarPrice 是预售价格
            if (decimal.Parse(replaceInfo.SellPrice) > zdPrice * (decimal)1.5 || decimal.Parse(replaceInfo.SellPrice) < 0)
            {
                msg += "预售价格不能小于等于0,并且不能大于厂商指导价的1.5倍(" + (zdPrice * (decimal)1.5).ToString() + ")【厂商指导价:" + (zdPrice).ToString() + "】<br/>";
            }

            if (decimal.Parse(replaceInfo.ReplacementCarUsedMiles) > 100 || decimal.Parse(replaceInfo.ReplacementCarUsedMiles) <= 0)
            {
                msg += "已行驶里程不能小于等于0,并且不能大于100<br/>";
            }


            if (msg != "")
            {
                return(null);
            }

            #endregion

            #region 获取置换订单实体类

            Entities.OrderRelpaceCar repCarModel = BLL.OrderRelpaceCar.Instance.GetOrderRelpaceCar(tid);
            if (repCarModel != null)
            {
                #region 修改值

                repCarModel.CarMasterID             = int.Parse(replaceInfo.CarMasterID);
                repCarModel.CarSerialID             = int.Parse(replaceInfo.CarSerialID);
                repCarModel.CarTypeID               = int.Parse(replaceInfo.CarTypeID);
                repCarModel.CarColor                = replaceInfo.CarColor;
                repCarModel.DMSMemberCode           = replaceInfo.DMSMemberCode;
                repCarModel.DMSMemberName           = replaceInfo.DMSMemberName;
                repCarModel.RepCarMasterID          = int.Parse(replaceInfo.RepCarMasterID);
                repCarModel.RepCarSerialID          = int.Parse(replaceInfo.RepCarSerialID);
                repCarModel.RepCarTypeId            = int.Parse(replaceInfo.RepCarTypeId);
                repCarModel.ReplacementCarColor     = replaceInfo.ReplacementcCarColor;
                repCarModel.ReplacementCarBuyMonth  = int.Parse(replaceInfo.ReplacementCarBuyMonth);
                repCarModel.ReplacementCarBuyYear   = int.Parse(replaceInfo.ReplacementCarBuyYear);
                repCarModel.RepCarProvinceID        = int.Parse(replaceInfo.RepCarProvinceID);
                repCarModel.RepCarCityID            = int.Parse(replaceInfo.RepCarCityID);
                repCarModel.RepCarCountyID          = int.Parse(replaceInfo.RepCarCountyID);
                repCarModel.ReplacementCarUsedMiles = decimal.Parse(replaceInfo.ReplacementCarUsedMiles);
                repCarModel.SalePrice               = decimal.Parse(replaceInfo.SellPrice);
                // repCarModel.CarPrice = decimal.Parse(replaceInfo.CarPrice);
                repCarModel.CallRecord = replaceInfo.CallRecord;
                repCarModel.UserName   = replaceInfo.UserName;

                #endregion
            }
            else
            {
                msg += "没有找到ID为" + tid.ToString() + "的联系记录信息";
            }

            #endregion

            return(repCarModel);
        }