示例#1
0
        private void Key_01_Modify_Car(dynamic data)
        {
            string           _openId = _http.Session["OpenId"].ToString();
            CT_Car_Inventory _car_In = new CT_Car_Inventory();

            if (data.CI_AU_Code == null)
            {
                _car_In.CI_AU_Code = getWechat_Member(_openId).MB_AU_Code;
            }
            else
            {
                _car_In.CI_AU_Code = (long)data.CI_AU_Code;
            }
            _car_In.CI_CS_Code = (int)data.CI_CS_Code;
            _car_In.CI_VIN     = null;
            _car_In.CI_Mileage = null;
            _car_In.CI_Licence = data.CI_Licence;

            _car_In.CI_Licence_dt = null;
            if (!string.IsNullOrEmpty((string)data.CI_Licence_dt))
            {
                _car_In.CI_Licence_dt = Convert.ToDateTime(data.CI_Licence_dt);
            }
            _car_In.CI_YR_Code      = null;
            _car_In.CI_Color_I      = null;
            _car_In.CI_Color_E      = null;
            _car_In.CI_Picture_FN   = null;
            _car_In.CI_Status       = "1";
            _car_In.CI_Activate_Tag = 1;
            _car_In.CI_Frame        = null;
            if (!string.IsNullOrEmpty((string)data.CI_Frame))
            {
                _car_In.CI_Frame = data.CI_Frame;
            }
            _car_In.CI_Driving = null;
            if (!string.IsNullOrEmpty((string)data.CI_Driving))
            {
                _car_In.CI_Driving = data.CI_Driving;
            }
            _car_In.CI_Driving_Type = null;
            if (!string.IsNullOrEmpty((string)data.CI_Driving_Type))
            {
                _car_In.CI_Driving_Type = data.CI_Driving_Type;
            }
            _car_In.CI_Driving_dt = null;
            if (!string.IsNullOrEmpty((string)data.CI_Driving_dt))
            {
                _car_In.CI_Driving_dt = Convert.ToDateTime(data.CI_Driving_dt);
            }
            _car_In.CI_Warr_St_dt = null;
            if (!string.IsNullOrEmpty((string)data.CI_Warr_St_dt))
            {
                _car_In.CI_Warr_St_dt = Convert.ToDateTime(data.CI_Warr_St_dt);
            }

            _car_In.CI_remarks = null;

            _object = _b_myCar.modify_Car(_car_In);
        }
示例#2
0
        private void CarBind_Adviser(dynamic data)
        {
            CT_Car_Inventory _car_o = new CT_Car_Inventory()
            {
                CI_AU_Code = (long)data.AU_Code,
                CI_Code    = (int)data.CI_Code,
                DE_Code    = (int)data.DE_Code,
                IS_Bind    = (bool)data.IS_Bind
            };

            _object = _b_myCar.CarBind_Adviser(_car_o);
        }
示例#3
0
 public int Modify_Car(CT_Car_Inventory _c)
 {
     #region 参数
     SqlParameter[] parameters =
     {
         new SqlParameter("@CI_AU_Code",      SqlDbType.BigInt),
         new SqlParameter("@CI_CS_Code",      SqlDbType.Int),
         new SqlParameter("@CI_VIN",          SqlDbType.VarChar,         20),
         new SqlParameter("@CI_Mileage",      SqlDbType.Int),
         new SqlParameter("@CI_Licence",      SqlDbType.NVarChar,        15),
         new SqlParameter("@CI_Licence_dt",   SqlDbType.SmallDateTime),
         new SqlParameter("@CI_YR_Code",      SqlDbType.TinyInt),
         new SqlParameter("@CI_Color_I",      SqlDbType.Int),
         new SqlParameter("@CI_Color_E",      SqlDbType.Int),
         new SqlParameter("@CI_Picture_FN",   SqlDbType.NVarChar,       100),
         new SqlParameter("@CI_Status",       SqlDbType.Char,             1),
         new SqlParameter("@CI_Activate_Tag", SqlDbType.TinyInt),
         new SqlParameter("@CI_Frame",        SqlDbType.NVarChar,       100),
         new SqlParameter("@CI_Driving",      SqlDbType.NVarChar,       100),
         new SqlParameter("@CI_Driving_Type", SqlDbType.NVarChar,       100),
         new SqlParameter("@CI_Driving_dt",   SqlDbType.SmallDateTime),
         new SqlParameter("@CI_Warr_St_dt",   SqlDbType.SmallDateTime),
         new SqlParameter("@CI_remarks",      SqlDbType.NVarChar, 100)
     };
     parameters[0].Value  = _c.CI_AU_Code;
     parameters[1].Value  = _c.CI_CS_Code;
     parameters[2].Value  = _c.CI_VIN;
     parameters[3].Value  = _c.CI_Mileage;
     parameters[4].Value  = _c.CI_Licence;
     parameters[5].Value  = _c.CI_Licence_dt;
     parameters[6].Value  = _c.CI_YR_Code;
     parameters[7].Value  = _c.CI_Color_I;
     parameters[8].Value  = _c.CI_Color_E;
     parameters[9].Value  = _c.CI_Picture_FN;
     parameters[10].Value = _c.CI_Status;
     parameters[11].Value = _c.CI_Activate_Tag;
     parameters[12].Value = _c.CI_Frame;
     parameters[13].Value = _c.CI_Driving;
     parameters[14].Value = _c.CI_Driving_Type;
     parameters[15].Value = _c.CI_Driving_dt;
     parameters[16].Value = _c.CI_Warr_St_dt;
     parameters[17].Value = _c.CI_remarks;
     #endregion
     return(SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "02_Modify_Car_W", parameters));
 }
示例#4
0
 public int CarBind_Adviser(CT_Car_Inventory o)
 {
     #region 参数
     SqlParameter[] parameters =
     {
         new SqlParameter("@AU_Code", SqlDbType.BigInt),
         new SqlParameter("@CI_Code", SqlDbType.Int),
         new SqlParameter("@DE_Code", SqlDbType.Int),
         new SqlParameter("@IS_Bind", SqlDbType.Bit)
     };
     parameters[0].Value = o.CI_AU_Code;
     parameters[1].Value = o.CI_Code;
     parameters[2].Value = o.DE_Code;
     parameters[3].Value = o.IS_Bind;
     #endregion
     int i = SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "[dbo].[03_Handle_CarBind_Adviser]", parameters);
     return(i);
 }
示例#5
0
    /// <summary>
    /// 车信息和联动列表
    /// </summary>
    /// <param name="id"></param>
    /// <param name="CI_CS_Code"></param>
    private void Get_Car_InventoryAndLendon(int id)
    {
        dynamic d  = new ExpandoObject();
        var     db = DBCRMTree.GetInstance();

        d.CT_Car_Inventory = CT_Car_Inventory.SingleOrDefault(id);

        d.CT_Car_Style = CT_Car_Style.SingleOrDefault(d.CT_Car_Inventory.CI_CS_Code);
        //Get_CT_Car_Style(d.CT_Car_Inventory.CM_Code, d.CT_Car_Inventory.CI_YR_Code);

        d.CT_Car_Inventory.CI_YR_Code = db.ExecuteScalar <Byte>(@"select YR_Code from [CT_Years]
where YR_Year = @0", d.CT_Car_Style.CS_Year);

        d.CT_Car_Inventory.CM_Code = d.CT_Car_Style.CS_CM_Code;
        // db.ExecuteScalar<int>(@"select cs_cm_code from [CT_Car_Style] where cs_code = @0", d.CT_Car_Inventory.CI_CS_Code);

        d.CT_Car_Inventory.MK_Code = db.ExecuteScalar <int>(@"select cm_mk_code from [CT_Car_Model]
where cm_code = @0", d.CT_Car_Inventory.CM_Code);

        d.CT_Car_Inventory.CP_Picture_FN = db.ExecuteScalar <string>(@"	SELECT [CP_Picture_FN] + ',' FROM [CT_Car_Pictures] 
	WHERE CP_CI_Code =@0 FOR XML PATH('')"    , d.CT_Car_Inventory.CI_Code);

        d.CT_Car_Model = Get_CT_Car_Model(d.CT_Car_Inventory.MK_Code, d.CT_Car_Inventory.CI_YR_Code);

        d.CT_Car_Style = Get_CT_Car_Style(d.CT_Car_Inventory.CM_Code, d.CT_Car_Inventory.CI_YR_Code);

        d.CT_Auto_Insurance = CT_Auto_Insurance.FirstOrDefault("where AI_CI_Code = @0 order by AI_Update_dt desc", d.CT_Car_Inventory.CI_Code);
        //        d.CT_Auto_Insurance = CT_Auto_Insurance.SingleOrDefault(@"Select TOP 1
        //              AI_Code,AI_CI_Code,AI_IC_Code,AI_IA_Code,AI_Policy,AI_Start_dt,AI_End_dt,AI_Update_dt
        //           from CT_Auto_Insurance where AI_CI_Code = @0 order by AI_Update_dt desc", d.CT_Car_Inventory.CI_Code);
        string sql_carInfo = string.Format(@"SELECT dbo.Get_Connect_Car(CI.CI_Code,1)AS CAR_CN,
	                    dbo.Get_Connect_Car(CI.CI_Code,2)AS CAR_EN,MK_Code,CM_Code,CS_Code,CI.* FROM CT_Make MK
                        INNER JOIN CT_Car_Model CM ON CM.CM_MK_Code=MK.MK_Code
                        INNER JOIN CT_Car_Style CS ON CS.CS_CM_Code=CM.CM_Code
                        INNER JOIN CT_Car_Inventory CI ON CI.CI_CS_Code=CS.CS_Code
                        WHERE CI.CI_Code=@0");

        d.carInfo = db.Query <dynamic>(sql_carInfo, id);
        Response.Write(JsonConvert.SerializeObject(d));
    }
示例#6
0
    /// <summary>
    /// 保存车信息
    /// </summary>
    /// <param name="data"></param>
    /// <param name="au_code"></param>
    private void Save_Car(dynamic data)
    {
        var db = DBCRMTree.GetInstance();

        try
        {
            using (var tran = db.GetTransaction())
            {
                var au_code        = (long)data.au_code;
                var s              = JsonConvert.SerializeObject(data.o);
                CT_Car_Inventory c = JsonConvert.DeserializeObject <CT_Car_Inventory>(s);
                var ci_code        = c.CI_Code;
                c.CI_AU_Code   = au_code;
                c.CI_Create_dt = DateTime.Now;
                if (c.CI_Code > 0)
                {
                    c.Update(new string[] {
                        "CI_AU_Code"
                        , "CI_Create_dt"
                        , "CI_CS_Code"
                        , "CI_VIN"
                        , "CI_Mileage"
                        , "CI_Licence"
                        , "CI_YR_Code"
                        , "CI_Color_I"
                        , "CI_Color_E"
                    });
                }
                else
                {
                    ci_code = (int)c.Insert();
                }

                CT_Auto_Insurance ai = JsonConvert.DeserializeObject <CT_Auto_Insurance>(s);
                ai.AI_CI_Code = c.CI_Code;
                if (db.Exists <CT_Auto_Insurance>("AI_CI_Code=@0", c.CI_Code))
                {
                    ai.AI_Update_dt = DateTime.Now;
                    string sql = @"UPDATE CT_Auto_Insurance
                    SET AI_IC_Code = @AI_IC_Code
                    ,AI_IA_Code = @AI_IA_Code
                    ,AI_Policy = @AI_Policy
                    ,AI_End_dt = @AI_End_dt
                    ,AI_Update_dt = @AI_Update_dt
                    WHERE AI_CI_Code=@AI_CI_Code";
                    db.Execute(sql, ai);
                }
                else
                {
                    ai.Insert();
                }

                var path = System.Configuration.ConfigurationManager.AppSettings["PLUploadPath"];
                if (string.IsNullOrWhiteSpace(path))
                {
                    path = "~/plupload/";
                }
                path = Server.MapPath(path);
                var path_save = path + "customer/";
                var path_temp = path + "customer_temp/";
                //添加图片
                if (!string.IsNullOrWhiteSpace(c.CP_Picture_FN))
                {
                    string[] imgs = c.CP_Picture_FN.Split(',');
                    foreach (var img in imgs)
                    {
                        if (!string.IsNullOrWhiteSpace(img))
                        {
                            var _CT_Car_Picture = new CT_Car_Picture();
                            _CT_Car_Picture.CP_CI_Code    = ci_code;
                            _CT_Car_Picture.CP_Picture_FN = img;
                            _CT_Car_Picture.CP_Update_dt  = DateTime.Now;
                            _CT_Car_Picture.Insert();
                            if (!Directory.Exists(path_save))
                            {
                                Directory.CreateDirectory(path_save);
                            }
                            if (File.Exists(path_temp + img))
                            {
                                File.Move(path_temp + img, path_save + img);
                            }
                        }
                    }
                }
                if (!string.IsNullOrWhiteSpace(c.Picture_Removed))
                {
                    string[] imgs_removed = c.Picture_Removed.Split(',');
                    foreach (var img in imgs_removed)
                    {
                        CT_Car_Picture.Delete("where [CP_Picture_FN]=@0", img);
                        var imgPath = path_save + img;
                        if (File.Exists(imgPath))
                        {
                            File.Delete(imgPath);
                        }
                    }
                }
                tran.Complete();
                Response.Write(JsonConvert.SerializeObject(new { CI_Code = ci_code, isOK = true }));
            }
        }
        catch (Exception ex)
        {
            db.AbortTransaction();
            Response.Write(JsonConvert.SerializeObject(new { isOK = false, msg = ex.Message }));
        }
    }
示例#7
0
 public int CarBind_Adviser(CT_Car_Inventory o)
 {
     return(_Car.CarBind_Adviser(o));
 }
示例#8
0
 /// <summary>
 /// 新增或是编辑都可以调用
 /// </summary>
 /// <param name="_c"></param>
 /// <returns></returns>
 public int modify_Car(CT_Car_Inventory _c)
 {
     return(_Car.Modify_Car(_c));
 }