コード例 #1
0
        /// <summary>
        /// 获取实体对象
        /// </summary>
        /// <param name="PKID">PKID</param>
        /// <returns>返回值</returns>
        public Common.Entity.CarColor GetCarColorByPKID(int PKID)
        {
            string sql = string.Format(@"select * from CarColor where PKID=@PKID");

            SqlParameter[] param =
            {
                new SqlParameter("@PKID", PKID)
            };
            try
            {
                Common.Entity.CarColor model = new Common.Entity.CarColor();
                DataTable dt = SqlHelper.GetDateTable(SqlHelper.connStr, CommandType.Text, sql, param);
                if (dt.Rows.Count > 0)
                {
                    model.PKID   = Convert.ToInt32(dt.Rows[0]["PKID"]);
                    model.Name   = dt.Rows[0]["Name"].ToString();
                    model.Code   = dt.Rows[0]["Code"].ToString();
                    model.CarID  = Convert.ToInt32(dt.Rows[0]["CarID"].ToString());
                    model.Remark = dt.Rows[0]["Remark"].ToString();
                }
                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        /// <summary>
        /// 新增一条记录
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>返回值</returns>
        public bool EastAdd(Common.Entity.CarColor model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"Insert into CarColor(CarID,Code,Name,Remark) 
                           Values (@CarID,@Code,@Name,@Remark)");
            strSql.Append(";SELECT @@IDENTITY");// 返回插入用户的主键
            SqlParameter[] param =
            {
                new SqlParameter("@Name",   model.Name),
                new SqlParameter("@Code",   model.Code),
                new SqlParameter("@CarID",  model.CarID),
                new SqlParameter("@Remark", model.Remark),
            };
            try
            {
                int result = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param);
                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public void EastSaveData(HttpContext context)
        {
            int    carId         = Convert.ToInt32(context.Request["hidCarId"]);
            int    HidCarColorId = Convert.ToInt32(context.Request["HidCarColorId"]);
            string name          = context.Request["colorName"];
            string code          = context.Request["colorCode"];

            BLL.CarInfo            bll   = new BLL.CarInfo();
            Common.Entity.CarColor model = new Common.Entity.CarColor();
            if (carId > 0)
            {
                if (HidCarColorId > 0)
                {
                    model.PKID  = HidCarColorId;
                    model.Code  = code;
                    model.Name  = name;
                    model.CarID = carId;
                    int result = bll.EastUpdate(model);
                    if (result > 0)
                    {
                        context.Response.Write("{\"msg\":\"保存成功。\",\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"msg\":\"保存失败。\",\"success\":false}");
                    }
                }
                else
                {
                    model.CarID = carId;
                    model.Code  = code;
                    model.Name  = name;
                    if (bll.EastExists(carId, code))
                    {
                        context.Response.Write("{\"state\":1, \"msg\":\"" + code + "\"}");
                    }
                    else if (bll.EastAdd(model))
                    {
                        context.Response.Write("{\"msg\":\"保存成功。\",\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"msg\":\"保存失败。\",\"success\":false}");
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 修改一条记录
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>返回值</returns>
        public int EastUpdate(Common.Entity.CarColor model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"Update CarColor set Name=@Name,Code=@Code,Remark=@Remark where PKID=@PKID");
            SqlParameter[] param =
            {
                new SqlParameter("@Name",   model.Name),
                new SqlParameter("@Code",   model.Code),
                new SqlParameter("@Remark", model.Remark),
                new SqlParameter("@PKID",   model.PKID)
            };
            try
            {
                return(Convert.ToInt32(SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param)));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
ファイル: CarInfo.cs プロジェクト: zhaojianMaster/VIPCustomer
 /// <summary>
 /// 修改一条记录
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns>返回值</returns>
 public int EastUpdate(Common.Entity.CarColor model)
 {
     return(new DAL.CarInfo().EastUpdate(model));
 }
コード例 #6
0
ファイル: CarInfo.cs プロジェクト: zhaojianMaster/VIPCustomer
 /// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns>返回值</returns>
 public bool EastAdd(Common.Entity.CarColor model)
 {
     return(new DAL.CarInfo().EastAdd(model));
 }