Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hotel_app.Model.Qkrxh model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Qkrxh(");
            strSql.Append("yydh,qymc,zjhm,krsj,krxm,hykh,xhrx,krxh,bz,is_top,is_select,shsc,czy,czsj)");
            strSql.Append(" values (");
            strSql.Append("@yydh,@qymc,@zjhm,@krsj,@krxm,@hykh,@xhrx,@krxh,@bz,@is_top,@is_select,@shsc,@czy,@czsj)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar, 100),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 100),
                new SqlParameter("@zjhm",      SqlDbType.VarChar, 100),
                new SqlParameter("@krsj",      SqlDbType.VarChar,  50),
                new SqlParameter("@krxm",      SqlDbType.VarChar, 100),
                new SqlParameter("@hykh",      SqlDbType.VarChar,  50),
                new SqlParameter("@xhrx",      SqlDbType.VarChar, 200),
                new SqlParameter("@krxh",      SqlDbType.VarChar, 600),
                new SqlParameter("@bz",        SqlDbType.VarChar, 500),
                new SqlParameter("@is_top",    SqlDbType.Bit,       1),
                new SqlParameter("@is_select", SqlDbType.Bit,       1),
                new SqlParameter("@shsc",      SqlDbType.Bit,       1),
                new SqlParameter("@czy",       SqlDbType.VarChar,  50),
                new SqlParameter("@czsj",      SqlDbType.DateTime)
            };
            parameters[0].Value  = model.yydh;
            parameters[1].Value  = model.qymc;
            parameters[2].Value  = model.zjhm;
            parameters[3].Value  = model.krsj;
            parameters[4].Value  = model.krxm;
            parameters[5].Value  = model.hykh;
            parameters[6].Value  = model.xhrx;
            parameters[7].Value  = model.krxh;
            parameters[8].Value  = model.bz;
            parameters[9].Value  = model.is_top;
            parameters[10].Value = model.is_select;
            parameters[11].Value = model.shsc;
            parameters[12].Value = model.czy;
            parameters[13].Value = model.czsj;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #2
0
        public string Qkrxh_add_edit_delete(string id, string yydh, string qymc, string krxm, string krsj, string zjhm, string hykh, string xhrx, string krxh, string bz, string czy, DateTime czsj, string add_edit, string xxzs)
        {
            string s = common_file.common_app.get_failure;

            BLL.Qkrxh   B_Qkrxh = new Hotel_app.BLL.Qkrxh();
            Model.Qkrxh M_Qkrxh = new Hotel_app.Model.Qkrxh();
            if (add_edit == common_file.common_app.get_add)
            {
                M_Qkrxh.yydh = yydh;  M_Qkrxh.qymc = qymc; M_Qkrxh.krxm = krxm; M_Qkrxh.krsj = krsj;
                M_Qkrxh.zjhm = zjhm; M_Qkrxh.hykh = hykh; M_Qkrxh.xhrx = xhrx; M_Qkrxh.krxh = krxh;
                M_Qkrxh.bz   = bz; M_Qkrxh.czy = czy; M_Qkrxh.czsj = czsj;
                if (B_Qkrxh.Add(M_Qkrxh) > 0)
                {
                    s = common_file.common_app.get_suc;
                }
            }
            if (add_edit == common_file.common_app.get_edit)
            {
                M_Qkrxh = B_Qkrxh.GetModel(int.Parse(id));
                if (M_Qkrxh != null)
                {
                    M_Qkrxh.yydh = yydh; M_Qkrxh.qymc = qymc; M_Qkrxh.krxm = krxm; M_Qkrxh.krsj = krsj;
                    M_Qkrxh.zjhm = zjhm; M_Qkrxh.hykh = hykh; M_Qkrxh.xhrx = xhrx; M_Qkrxh.krxh = krxh;
                    M_Qkrxh.bz   = bz; M_Qkrxh.czy = czy; M_Qkrxh.czsj = czsj;
                    M_Qkrxh.id   = int.Parse(id);
                    if (B_Qkrxh.Update(M_Qkrxh))
                    {
                        s = common_file.common_app.get_suc;
                    }
                }
            }
            else
            if (add_edit == common_file.common_app.get_delete)
            {
                if (B_Qkrxh.Delete(int.Parse(id)) == true)
                {
                    s = common_file.common_app.get_suc;
                }
            }
            return(s);
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hotel_app.Model.Qkrxh GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,yydh,qymc,zjhm,krsj,krxm,hykh,xhrx,krxh,bz,is_top,is_select,shsc,czy,czsj from Qkrxh ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Hotel_app.Model.Qkrxh model = new Hotel_app.Model.Qkrxh();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["yydh"] != null && ds.Tables[0].Rows[0]["yydh"].ToString() != "")
                {
                    model.yydh = ds.Tables[0].Rows[0]["yydh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["qymc"] != null && ds.Tables[0].Rows[0]["qymc"].ToString() != "")
                {
                    model.qymc = ds.Tables[0].Rows[0]["qymc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["zjhm"] != null && ds.Tables[0].Rows[0]["zjhm"].ToString() != "")
                {
                    model.zjhm = ds.Tables[0].Rows[0]["zjhm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krsj"] != null && ds.Tables[0].Rows[0]["krsj"].ToString() != "")
                {
                    model.krsj = ds.Tables[0].Rows[0]["krsj"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krxm"] != null && ds.Tables[0].Rows[0]["krxm"].ToString() != "")
                {
                    model.krxm = ds.Tables[0].Rows[0]["krxm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["hykh"] != null && ds.Tables[0].Rows[0]["hykh"].ToString() != "")
                {
                    model.hykh = ds.Tables[0].Rows[0]["hykh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["xhrx"] != null && ds.Tables[0].Rows[0]["xhrx"].ToString() != "")
                {
                    model.xhrx = ds.Tables[0].Rows[0]["xhrx"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krxh"] != null && ds.Tables[0].Rows[0]["krxh"].ToString() != "")
                {
                    model.krxh = ds.Tables[0].Rows[0]["krxh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["bz"] != null && ds.Tables[0].Rows[0]["bz"].ToString() != "")
                {
                    model.bz = ds.Tables[0].Rows[0]["bz"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["is_top"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_top"].ToString().ToLower() == "true"))
                    {
                        model.is_top = true;
                    }
                    else
                    {
                        model.is_top = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["is_select"] != null && ds.Tables[0].Rows[0]["is_select"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["is_select"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_select"].ToString().ToLower() == "true"))
                    {
                        model.is_select = true;
                    }
                    else
                    {
                        model.is_select = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["shsc"] != null && ds.Tables[0].Rows[0]["shsc"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["shsc"].ToString() == "1") || (ds.Tables[0].Rows[0]["shsc"].ToString().ToLower() == "true"))
                    {
                        model.shsc = true;
                    }
                    else
                    {
                        model.shsc = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["czy"] != null && ds.Tables[0].Rows[0]["czy"].ToString() != "")
                {
                    model.czy = ds.Tables[0].Rows[0]["czy"].ToString();
                }
                if (ds.Tables[0].Rows[0]["czsj"] != null && ds.Tables[0].Rows[0]["czsj"].ToString() != "")
                {
                    model.czsj = DateTime.Parse(ds.Tables[0].Rows[0]["czsj"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hotel_app.Model.Qkrxh model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Qkrxh set ");
            strSql.Append("yydh=@yydh,");
            strSql.Append("qymc=@qymc,");
            strSql.Append("zjhm=@zjhm,");
            strSql.Append("krsj=@krsj,");
            strSql.Append("krxm=@krxm,");
            strSql.Append("hykh=@hykh,");
            strSql.Append("xhrx=@xhrx,");
            strSql.Append("krxh=@krxh,");
            strSql.Append("bz=@bz,");
            strSql.Append("is_top=@is_top,");
            strSql.Append("is_select=@is_select,");
            strSql.Append("shsc=@shsc,");
            strSql.Append("czy=@czy,");
            strSql.Append("czsj=@czsj");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar,   100),
                new SqlParameter("@qymc",      SqlDbType.VarChar,   100),
                new SqlParameter("@zjhm",      SqlDbType.VarChar,   100),
                new SqlParameter("@krsj",      SqlDbType.VarChar,    50),
                new SqlParameter("@krxm",      SqlDbType.VarChar,   100),
                new SqlParameter("@hykh",      SqlDbType.VarChar,    50),
                new SqlParameter("@xhrx",      SqlDbType.VarChar,   200),
                new SqlParameter("@krxh",      SqlDbType.VarChar,   600),
                new SqlParameter("@bz",        SqlDbType.VarChar,   500),
                new SqlParameter("@is_top",    SqlDbType.Bit,         1),
                new SqlParameter("@is_select", SqlDbType.Bit,         1),
                new SqlParameter("@shsc",      SqlDbType.Bit,         1),
                new SqlParameter("@czy",       SqlDbType.VarChar,    50),
                new SqlParameter("@czsj",      SqlDbType.DateTime),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.yydh;
            parameters[1].Value  = model.qymc;
            parameters[2].Value  = model.zjhm;
            parameters[3].Value  = model.krsj;
            parameters[4].Value  = model.krxm;
            parameters[5].Value  = model.hykh;
            parameters[6].Value  = model.xhrx;
            parameters[7].Value  = model.krxh;
            parameters[8].Value  = model.bz;
            parameters[9].Value  = model.is_top;
            parameters[10].Value = model.is_select;
            parameters[11].Value = model.shsc;
            parameters[12].Value = model.czy;
            parameters[13].Value = model.czsj;
            parameters[14].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }