Esempio n. 1
0
File: Car.cs Progetto: WISD/WisdCar
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WisdCar.Model.PO.CarPO GetModel(int CarID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CarID,CarNo,Brand,CarModel,Capacity,Color,FrameNo,EngineNo,MaintainKM,InsureDate,ASDate,CustomerID,LogicalStatus,CreatorID,CreatedDate,LastModifierID,LastModifiedDate,Reserved1,Reserved2,Reserved3 from Car ");
            strSql.Append(" where customerid=@CarID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CarID", SqlDbType.Int, 4)
            };
            parameters[0].Value = CarID;

            WisdCar.Model.PO.CarPO model = new WisdCar.Model.PO.CarPO();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
File: Car.cs Progetto: WISD/WisdCar
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WisdCar.Model.PO.CarPO DataRowToModel(DataRow row)
 {
     WisdCar.Model.PO.CarPO model=new WisdCar.Model.PO.CarPO();
     if (row != null)
     {
         if(row["CarID"]!=null && row["CarID"].ToString()!="")
         {
             model.CarID=int.Parse(row["CarID"].ToString());
         }
         if(row["CarNo"]!=null)
         {
             model.CarNo=row["CarNo"].ToString();
         }
         if(row["Brand"]!=null)
         {
             model.Brand=row["Brand"].ToString();
         }
         if(row["CarModel"]!=null)
         {
             model.CarModel=row["CarModel"].ToString();
         }
         if(row["Capacity"]!=null)
         {
             model.Capacity=row["Capacity"].ToString();
         }
         if(row["Color"]!=null)
         {
             model.Color=row["Color"].ToString();
         }
         if(row["FrameNo"]!=null)
         {
             model.FrameNo=row["FrameNo"].ToString();
         }
         if(row["EngineNo"]!=null)
         {
             model.EngineNo=row["EngineNo"].ToString();
         }
         if(row["MaintainKM"]!=null)
         {
             model.MaintainKM=row["MaintainKM"].ToString();
         }
         if(row["InsureDate"]!=null && row["InsureDate"].ToString()!="")
         {
             model.InsureDate=(DateTime?)DateTime.Parse(row["InsureDate"].ToString());
         }
         if(row["ASDate"]!=null && row["ASDate"].ToString()!="")
         {
             model.ASDate=(DateTime?)DateTime.Parse(row["ASDate"].ToString());
         }
         if(row["CustomerID"]!=null && row["CustomerID"].ToString()!="")
         {
             model.CustomerID=int.Parse(row["CustomerID"].ToString());
         }
         if(row["LogicalStatus"]!=null && row["LogicalStatus"].ToString()!="")
         {
             model.LogicalStatus=int.Parse(row["LogicalStatus"].ToString());
         }
         if(row["CreatorID"]!=null)
         {
             model.CreatorID=row["CreatorID"].ToString();
         }
         if(row["CreatedDate"]!=null && row["CreatedDate"].ToString()!="")
         {
             model.CreatedDate=DateTime.Parse(row["CreatedDate"].ToString());
         }
         if(row["LastModifierID"]!=null)
         {
             model.LastModifierID=row["LastModifierID"].ToString();
         }
         if(row["LastModifiedDate"]!=null && row["LastModifiedDate"].ToString()!="")
         {
             model.LastModifiedDate=DateTime.Parse(row["LastModifiedDate"].ToString());
         }
         if(row["Reserved1"]!=null)
         {
             model.Reserved1=row["Reserved1"].ToString();
         }
         if(row["Reserved2"]!=null)
         {
             model.Reserved2=row["Reserved2"].ToString();
         }
         if(row["Reserved3"]!=null)
         {
             model.Reserved3=row["Reserved3"].ToString();
         }
     }
     return model;
 }
Esempio n. 3
0
File: Car.cs Progetto: WISD/WisdCar
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WisdCar.Model.PO.CarPO GetModel(int CarID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 CarID,CarNo,Brand,CarModel,Capacity,Color,FrameNo,EngineNo,MaintainKM,InsureDate,ASDate,CustomerID,LogicalStatus,CreatorID,CreatedDate,LastModifierID,LastModifiedDate,Reserved1,Reserved2,Reserved3 from Car ");
            strSql.Append(" where customerid=@CarID");
            SqlParameter[] parameters = {
                    new SqlParameter("@CarID", SqlDbType.Int,4)
            };
            parameters[0].Value = CarID;

            WisdCar.Model.PO.CarPO model=new WisdCar.Model.PO.CarPO();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Esempio n. 4
0
File: Car.cs Progetto: WISD/WisdCar
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WisdCar.Model.PO.CarPO model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Car(");
            strSql.Append("CarNo,Brand,CarModel,Capacity,Color,FrameNo,EngineNo,MaintainKM,InsureDate,ASDate,CustomerID,LogicalStatus,CreatorID,CreatedDate,LastModifierID,LastModifiedDate,Reserved1,Reserved2,Reserved3)");
            strSql.Append(" values (");
            strSql.Append("@CarNo,@Brand,@CarModel,@Capacity,@Color,@FrameNo,@EngineNo,@MaintainKM,@InsureDate,@ASDate,@CustomerID,@LogicalStatus,@CreatorID,@CreatedDate,@LastModifierID,@LastModifiedDate,@Reserved1,@Reserved2,@Reserved3)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CarNo",            SqlDbType.NVarChar,   50),
                new SqlParameter("@Brand",            SqlDbType.NVarChar,   50),
                new SqlParameter("@CarModel",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Capacity",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Color",            SqlDbType.NVarChar,   50),
                new SqlParameter("@FrameNo",          SqlDbType.NVarChar,   50),
                new SqlParameter("@EngineNo",         SqlDbType.NVarChar,   50),
                new SqlParameter("@MaintainKM",       SqlDbType.NVarChar,   50),
                new SqlParameter("@InsureDate",       SqlDbType.DateTime),
                new SqlParameter("@ASDate",           SqlDbType.DateTime),
                new SqlParameter("@CustomerID",       SqlDbType.Int,         4),
                new SqlParameter("@LogicalStatus",    SqlDbType.Int,         4),
                new SqlParameter("@CreatorID",        SqlDbType.NVarChar,   50),
                new SqlParameter("@CreatedDate",      SqlDbType.DateTime),
                new SqlParameter("@LastModifierID",   SqlDbType.NVarChar,   50),
                new SqlParameter("@LastModifiedDate", SqlDbType.DateTime),
                new SqlParameter("@Reserved1",        SqlDbType.NVarChar,  100),
                new SqlParameter("@Reserved2",        SqlDbType.NVarChar,  100),
                new SqlParameter("@Reserved3",        SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.CarNo;
            parameters[1].Value  = model.Brand;
            parameters[2].Value  = model.CarModel;
            parameters[3].Value  = model.Capacity;
            parameters[4].Value  = model.Color;
            parameters[5].Value  = model.FrameNo;
            parameters[6].Value  = model.EngineNo;
            parameters[7].Value  = model.MaintainKM;
            parameters[8].Value  = model.InsureDate;
            parameters[9].Value  = model.ASDate;
            parameters[10].Value = model.CustomerID;
            parameters[11].Value = model.LogicalStatus;
            parameters[12].Value = model.CreatorID;
            parameters[13].Value = model.CreatedDate;
            parameters[14].Value = model.LastModifierID;
            parameters[15].Value = model.LastModifiedDate;
            parameters[16].Value = model.Reserved1;
            parameters[17].Value = model.Reserved2;
            parameters[18].Value = model.Reserved3;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 5
0
File: Car.cs Progetto: WISD/WisdCar
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WisdCar.Model.PO.CarPO DataRowToModel(DataRow row)
 {
     WisdCar.Model.PO.CarPO model = new WisdCar.Model.PO.CarPO();
     if (row != null)
     {
         if (row["CarID"] != null && row["CarID"].ToString() != "")
         {
             model.CarID = int.Parse(row["CarID"].ToString());
         }
         if (row["CarNo"] != null)
         {
             model.CarNo = row["CarNo"].ToString();
         }
         if (row["Brand"] != null)
         {
             model.Brand = row["Brand"].ToString();
         }
         if (row["CarModel"] != null)
         {
             model.CarModel = row["CarModel"].ToString();
         }
         if (row["Capacity"] != null)
         {
             model.Capacity = row["Capacity"].ToString();
         }
         if (row["Color"] != null)
         {
             model.Color = row["Color"].ToString();
         }
         if (row["FrameNo"] != null)
         {
             model.FrameNo = row["FrameNo"].ToString();
         }
         if (row["EngineNo"] != null)
         {
             model.EngineNo = row["EngineNo"].ToString();
         }
         if (row["MaintainKM"] != null)
         {
             model.MaintainKM = row["MaintainKM"].ToString();
         }
         if (row["InsureDate"] != null && row["InsureDate"].ToString() != "")
         {
             model.InsureDate = (DateTime?)DateTime.Parse(row["InsureDate"].ToString());
         }
         if (row["ASDate"] != null && row["ASDate"].ToString() != "")
         {
             model.ASDate = (DateTime?)DateTime.Parse(row["ASDate"].ToString());
         }
         if (row["CustomerID"] != null && row["CustomerID"].ToString() != "")
         {
             model.CustomerID = int.Parse(row["CustomerID"].ToString());
         }
         if (row["LogicalStatus"] != null && row["LogicalStatus"].ToString() != "")
         {
             model.LogicalStatus = int.Parse(row["LogicalStatus"].ToString());
         }
         if (row["CreatorID"] != null)
         {
             model.CreatorID = row["CreatorID"].ToString();
         }
         if (row["CreatedDate"] != null && row["CreatedDate"].ToString() != "")
         {
             model.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString());
         }
         if (row["LastModifierID"] != null)
         {
             model.LastModifierID = row["LastModifierID"].ToString();
         }
         if (row["LastModifiedDate"] != null && row["LastModifiedDate"].ToString() != "")
         {
             model.LastModifiedDate = DateTime.Parse(row["LastModifiedDate"].ToString());
         }
         if (row["Reserved1"] != null)
         {
             model.Reserved1 = row["Reserved1"].ToString();
         }
         if (row["Reserved2"] != null)
         {
             model.Reserved2 = row["Reserved2"].ToString();
         }
         if (row["Reserved3"] != null)
         {
             model.Reserved3 = row["Reserved3"].ToString();
         }
     }
     return(model);
 }
Esempio n. 6
0
File: Car.cs Progetto: WISD/WisdCar
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WisdCar.Model.PO.CarPO model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Car set ");
            strSql.Append("CarNo=@CarNo,");
            strSql.Append("Brand=@Brand,");
            strSql.Append("CarModel=@CarModel,");
            strSql.Append("Capacity=@Capacity,");
            strSql.Append("Color=@Color,");
            strSql.Append("FrameNo=@FrameNo,");
            strSql.Append("EngineNo=@EngineNo,");
            strSql.Append("MaintainKM=@MaintainKM,");
            strSql.Append("InsureDate=@InsureDate,");
            strSql.Append("ASDate=@ASDate,");
            strSql.Append("CustomerID=@CustomerID,");
            strSql.Append("LogicalStatus=@LogicalStatus,");
            //strSql.Append("CreatorID=@CreatorID,");
            //strSql.Append("CreatedDate=@CreatedDate,");
            strSql.Append("LastModifierID=@LastModifierID,");
            strSql.Append("LastModifiedDate=@LastModifiedDate,");
            strSql.Append("Reserved1=@Reserved1,");
            strSql.Append("Reserved2=@Reserved2,");
            strSql.Append("Reserved3=@Reserved3");
            strSql.Append(" where CarID=@CarID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CarNo",            SqlDbType.NVarChar,   50),
                new SqlParameter("@Brand",            SqlDbType.NVarChar,   50),
                new SqlParameter("@CarModel",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Capacity",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Color",            SqlDbType.NVarChar,   50),
                new SqlParameter("@FrameNo",          SqlDbType.NVarChar,   50),
                new SqlParameter("@EngineNo",         SqlDbType.NVarChar,   50),
                new SqlParameter("@MaintainKM",       SqlDbType.NVarChar,   50),
                new SqlParameter("@InsureDate",       SqlDbType.DateTime),
                new SqlParameter("@ASDate",           SqlDbType.DateTime),
                new SqlParameter("@CustomerID",       SqlDbType.Int,         4),
                new SqlParameter("@LogicalStatus",    SqlDbType.Int,         4),
                //new SqlParameter("@CreatorID", SqlDbType.NVarChar,50),
                //new SqlParameter("@CreatedDate", SqlDbType.DateTime),
                new SqlParameter("@LastModifierID",   SqlDbType.NVarChar,   50),
                new SqlParameter("@LastModifiedDate", SqlDbType.DateTime),
                new SqlParameter("@Reserved1",        SqlDbType.NVarChar,  100),
                new SqlParameter("@Reserved2",        SqlDbType.NVarChar,  100),
                new SqlParameter("@Reserved3",        SqlDbType.NVarChar,  100),
                new SqlParameter("@CarID",            SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.CarNo;
            parameters[1].Value  = model.Brand;
            parameters[2].Value  = model.CarModel;
            parameters[3].Value  = model.Capacity;
            parameters[4].Value  = model.Color;
            parameters[5].Value  = model.FrameNo;
            parameters[6].Value  = model.EngineNo;
            parameters[7].Value  = model.MaintainKM;
            parameters[8].Value  = model.InsureDate;
            parameters[9].Value  = model.ASDate;
            parameters[10].Value = model.CustomerID;
            parameters[11].Value = model.LogicalStatus;
            //parameters[12].Value = model.CreatorID;
            //parameters[13].Value = model.CreatedDate;
            parameters[12].Value = model.LastModifierID;
            parameters[13].Value = model.LastModifiedDate;
            parameters[14].Value = model.Reserved1;
            parameters[15].Value = model.Reserved2;
            parameters[16].Value = model.Reserved3;
            parameters[17].Value = model.CarID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 更新一条数据带事务
        /// </summary>
        public bool Update(WisdCar.Model.PO.CustomerPO customer, WisdCar.Model.PO.CarPO car)
        {
            StringBuilder strSqlcus = new StringBuilder();

            strSqlcus.Append("update Customer set ");
            strSqlcus.Append("Name=@Name,");
            strSqlcus.Append("MobileNO=@MobileNO,");
            strSqlcus.Append("Sex=@Sex,");
            strSqlcus.Append("Birthday=@Birthday,");
            strSqlcus.Append("ICNo=@ICNo,");
            strSqlcus.Append("Weixin=@Weixin,");
            strSqlcus.Append("Company=@Company,");
            strSqlcus.Append("CardFlag=@CardFlag,");
            strSqlcus.Append("LogicalStatus=@LogicalStatus,");
            //strSql.Append("CreatorID=@CreatorID,");
            //strSql.Append("CreatedDate=@CreatedDate,");
            strSqlcus.Append("LastModifierID=@LastModifierID,");
            strSqlcus.Append("LastModifiedDate=@LastModifiedDate");
            strSqlcus.Append(" where CustomerID=@CustomerID");
            SqlParameter[] spcus =
            {
                new SqlParameter("@Name",             SqlDbType.NVarChar,  50),
                new SqlParameter("@MobileNO",         SqlDbType.NVarChar,  50),
                new SqlParameter("@Sex",              SqlDbType.NVarChar,  50),
                new SqlParameter("@Birthday",         SqlDbType.NVarChar,  50),
                new SqlParameter("@ICNo",             SqlDbType.NVarChar,  50),
                new SqlParameter("@Weixin",           SqlDbType.NVarChar,  50),
                new SqlParameter("@Company",          SqlDbType.NVarChar,  50),
                new SqlParameter("@CardFlag",         SqlDbType.Int,        4),
                new SqlParameter("@LogicalStatus",    SqlDbType.Int,        4),
                //new SqlParameter("@CreatorID", SqlDbType.NVarChar,50),
                //new SqlParameter("@CreatedDate", SqlDbType.DateTime),
                new SqlParameter("@LastModifierID",   SqlDbType.NVarChar,  50),
                new SqlParameter("@LastModifiedDate", SqlDbType.DateTime),
                new SqlParameter("@CustomerID",       SqlDbType.Int, 4)
            };
            spcus[0].Value = customer.Name;
            spcus[1].Value = customer.MobileNO;
            spcus[2].Value = customer.Sex;
            spcus[3].Value = customer.Birthday;
            spcus[4].Value = customer.ICNo;
            spcus[5].Value = customer.Weixin;
            spcus[6].Value = customer.Company;
            spcus[7].Value = customer.CardFlag;
            spcus[8].Value = customer.LogicalStatus;
            //parameters[9].Value = model.CreatorID;
            //parameters[10].Value = model.CreatedDate;
            spcus[9].Value  = customer.LastModifierID;
            spcus[10].Value = customer.LastModifiedDate;
            spcus[11].Value = customer.CustomerID;

            StringBuilder strSqlcar = new StringBuilder();

            strSqlcar.Append("update Car set ");
            strSqlcar.Append("CarNo=@CarNo,");
            strSqlcar.Append("Brand=@Brand,");
            strSqlcar.Append("CarModel=@CarModel,");
            strSqlcar.Append("Capacity=@Capacity,");
            strSqlcar.Append("Color=@Color,");
            strSqlcar.Append("FrameNo=@FrameNo,");
            strSqlcar.Append("EngineNo=@EngineNo,");
            strSqlcar.Append("MaintainKM=@MaintainKM,");
            strSqlcar.Append("InsureDate=@InsureDate,");
            strSqlcar.Append("ASDate=@ASDate,");
            strSqlcar.Append("CustomerID=@CustomerID,");
            strSqlcar.Append("LogicalStatus=@LogicalStatus,");
            //strSql.Append("CreatorID=@CreatorID,");
            //strSql.Append("CreatedDate=@CreatedDate,");
            strSqlcar.Append("LastModifierID=@LastModifierID,");
            strSqlcar.Append("LastModifiedDate=@LastModifiedDate");
            strSqlcar.Append(" where CarID=@CarID");
            SqlParameter[] pscar =
            {
                new SqlParameter("@CarNo",            SqlDbType.NVarChar,  50),
                new SqlParameter("@Brand",            SqlDbType.NVarChar,  50),
                new SqlParameter("@CarModel",         SqlDbType.NVarChar,  50),
                new SqlParameter("@Capacity",         SqlDbType.NVarChar,  50),
                new SqlParameter("@Color",            SqlDbType.NVarChar,  50),
                new SqlParameter("@FrameNo",          SqlDbType.NVarChar,  50),
                new SqlParameter("@EngineNo",         SqlDbType.NVarChar,  50),
                new SqlParameter("@MaintainKM",       SqlDbType.NVarChar,  50),
                new SqlParameter("@InsureDate",       SqlDbType.DateTime),
                new SqlParameter("@ASDate",           SqlDbType.DateTime),
                new SqlParameter("@CustomerID",       SqlDbType.Int,        4),
                new SqlParameter("@LogicalStatus",    SqlDbType.Int,        4),
                //new SqlParameter("@CreatorID", SqlDbType.NVarChar,50),
                //new SqlParameter("@CreatedDate", SqlDbType.DateTime),
                new SqlParameter("@LastModifierID",   SqlDbType.NVarChar,  50),
                new SqlParameter("@LastModifiedDate", SqlDbType.DateTime),
                new SqlParameter("@CarID",            SqlDbType.Int, 4)
            };
            pscar[0].Value  = car.CarNo;
            pscar[1].Value  = car.Brand;
            pscar[2].Value  = car.CarModel;
            pscar[3].Value  = car.Capacity;
            pscar[4].Value  = car.Color;
            pscar[5].Value  = car.FrameNo;
            pscar[6].Value  = car.EngineNo;
            pscar[7].Value  = car.MaintainKM;
            pscar[8].Value  = car.InsureDate;
            pscar[9].Value  = car.ASDate;
            pscar[10].Value = customer.CustomerID;
            pscar[11].Value = customer.LogicalStatus;
            //parameters[12].Value = model.CreatorID;
            //parameters[13].Value = model.CreatedDate;
            pscar[12].Value = car.LastModifierID;
            pscar[13].Value = car.LastModifiedDate;
            pscar[14].Value = car.CarID;

            Hashtable hs = new Hashtable();

            hs.Add(strSqlcus, spcus);
            hs.Add(strSqlcar, pscar);
            try
            {
                DbHelperSQL.ExecuteSqlTranWithIndentity(hs);
                return(true);
            }
            catch
            {
                return(false);
            }
        }