Ejemplo n.º 1
0
        public static void ModifyGuestCategory(GuestCategory guestCategory)
        {
            string sql =
                "UPDATE GuestCategory " +
                "SET " +
                "CategoryName = @CategoryName " +
                "WHERE CategoryID = @CategoryID";


            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@CategoryID", guestCategory.CategoryID),
                    new SqlParameter("@CategoryName", guestCategory.CategoryName)
                };

                DBHelper.ExecuteCommand(sql, para);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据SQL语句获取客人类型列表
        /// </summary>
        /// <param name="safeSql">查询sql语句</param>
        /// <returns>IList<GuestCategory></returns>
        private static IList <GuestCategory> GetGuestCategoriesBySql(string safeSql)
        {
            List <GuestCategory> list = new List <GuestCategory>();//创建泛型集合

            try
            {
                DataTable table = DBHelper.GetDataSet(safeSql);//执行sql语句
                //遍历数据表记录获取数据
                foreach (DataRow row in table.Rows)
                {
                    GuestCategory guestCategory = new GuestCategory();

                    guestCategory.CategoryID   = (int)row["CategoryID"];
                    guestCategory.CategoryName = (string)row["CategoryName"];

                    list.Add(guestCategory); //添加到集合对象中
                }

                return(list);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Ejemplo n.º 3
0
/// <summary>
/// 根据ID获取实体对象
/// </summary>
/// <param name="categoryID"></param>
/// <returns></returns>
        public static GuestCategory GetGuestCategoryByCategoryID(int categoryID)
        {
            string sql = "SELECT * FROM GuestCategory WHERE CategoryID = @CategoryID";//sql语句

            try
            {
                using (SqlDataReader reader = DBHelper.GetReader(sql, new SqlParameter("@CategoryID", categoryID)))
                {
                    if (reader.Read())
                    {
                        GuestCategory guestCategory = new GuestCategory();

                        guestCategory.CategoryID   = (int)reader["CategoryID"];
                        guestCategory.CategoryName = (string)reader["CategoryName"];
                        return(guestCategory);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Ejemplo n.º 4
0
        public GuestCategory CreateModel()
        {
            var guestCategory = new GuestCategory();

            guestCategory.Name        = this.Name;
            guestCategory.Coefficient = this.Coefficient;

            return(guestCategory);
        }
    private void BindGuestCategories()
    {
        DataTable table = new GuestCategory().SelectAll();

        drpCategory.DataSource     = table;
        drpCategory.DataTextField  = table.Columns["CategoryDescription"].ToString();
        drpCategory.DataValueField = table.Columns["GuestCategory_ID"].ToString();
        drpCategory.DataBind();
    }
Ejemplo n.º 6
0
        /// <summary>
        /// 单击DataGridView控件中的单元格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvGuest_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //显示编辑区
            VisibleEditSection();
            //获取双击客人信息的ID
            id = Convert.ToInt32(this.dgvGuest.Rows[e.RowIndex].Cells["GuestID"].Value);
            //调用业务逻辑层通过客人ID得到客房信息
            guest = GuestManager.GetGuestByID(Convert.ToInt32(id));
            //将客人信息回绑到编辑控件
            this.txtName.Text  = guest.Name.ToString();
            this.txtSex.Text   = guest.Sex.ToString();
            this.txtPhone.Text = guest.Mobile.ToString();
            //Room room = RoomManager.GetRoomByRoomId(Convert.ToInt32(guest.RoomId));
            this.txtRoomID.Text     = guest.RoomId.ToString();
            this.txtArriveTime.Text = guest.ArriveTime.ToString();
            this.txtLeaveTime.Text  = guest.LeaveTime.ToString();
            //调用业务逻辑层通过客人类型ID得到客人类型信息
            GuestCategory gc = GuestCategoryManager.GetGuestCategoryByCategoryID(Convert.ToInt32(guest.CategoryId));

            //回绑客房类型信息
            this.cboCatagory.Text = gc.CategoryName.ToString();
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="guestCategory"></param>
        /// <returns></returns>
        public static GuestCategory AddGuestCategory(GuestCategory guestCategory)
        {
            string sql =
                "INSERT GuestCategory (CategoryName)" +
                "VALUES (@CategoryName)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@CategoryName", guestCategory.CategoryName)
                };

                int newId = DBHelper.GetScalar(sql, para);
                return(GetGuestCategoryByCategoryID(newId));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Ejemplo n.º 8
0
 public void Update(GuestCategory guestCategory)
 {
     guestCategory.Name        = this.Name;
     guestCategory.Coefficient = this.Coefficient;
 }
Ejemplo n.º 9
0
 public GuestCategoryDto(GuestCategory guestCategory)
 {
     this.Id          = guestCategory.Id;
     this.Name        = guestCategory.Name;
     this.Coefficient = guestCategory.Coefficient;
 }
Ejemplo n.º 10
0
 public static GuestCategory AddGuestCategory(GuestCategory guestCategory)
 {
     return(GuestCategoryService.AddGuestCategory(guestCategory));
 }
Ejemplo n.º 11
0
 public static void ModifyGuestCategory(GuestCategory guestCategory)
 {
     GuestCategoryService.ModifyGuestCategory(guestCategory);
 }
Ejemplo n.º 12
0
 public static void DeleteGuestCategory(GuestCategory guestCategory)
 {
     GuestCategoryService.DeleteGuestCategory(guestCategory);
 }
Ejemplo n.º 13
0
 public static void DeleteGuestCategory(GuestCategory guestCategory)
 {
     DeleteGuestCategoryByCategoryID(guestCategory.CategoryID);
 }