Exemplo n.º 1
0
        /// <summary>
        /// 选择节点事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvBookType_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //获取当前选择节点
            TreeNode         tn     = tvBookType.SelectedNode;
            int              typeid = Convert.ToInt32(tn.Tag.ToString());
            BookTypeExtModel model  = btbll.GetBookTypeId(typeid);

            if (model == null)
            {
                MessageBox.Show("获取图书类别信息出错");
                return;
            }
            else
            {
                if (model.ParentTypeId == 0)
                {
                    txtParentTypeId.Text   = "NULL";
                    txtParentTypeName.Text = "NULL";
                }
                else
                {
                    txtParentTypeId.Text   = model.ParentTypeId2.ToString();
                    txtParentTypeName.Text = model.ParentTypeName;
                }
                txtTypeId.Text   = model.TypeId.ToString();
                txtTypeName.Text = model.TypeName;
                txtDESC.Text     = model.TypeDESC;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据类别Id得到类别信息及父类信息
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        public BookTypeExtModel GetBookTypeId(int typeId)
        {
            string sql = "select * from (select TypeId, TypeName, TypeDESC, ParentTypeId from booktype) a left join (select TypeId as ParentTypeId2, TypeName as ParentTypeName,TypeDESC as ParentTypeDESC from booktype) b on a.ParentTypeId = b.ParentTypeid2 where a.typeid = @typeId";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("TypeId", typeId)
            };
            BookTypeExtModel model = null;
            DataSet          ds    = helper.GetDataSetSql(sql, para);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model = ListDataSet.DataSetToIList <BookTypeExtModel>(ds, 0).ToList().First();
            }
            return(model);
        }
Exemplo n.º 3
0
        private void Editbkfrm()
        {
            lblTiele.Text = "【修改图书】";
            BookExtModel bkinfo = bkbll.GetBookModelById(bookid);

            if (bkinfo != null)
            {
                //页面控件赋值
                txtBookId.Text        = bkinfo.BookId;
                txtBookId.ReadOnly    = true;
                txtBookISBN.Text      = bkinfo.ISBN;
                txtBookName.Text      = bkinfo.BookName;
                txtBookAuthor.Text    = bkinfo.BookAuthor;
                txtBookPrice.Text     = bkinfo.BookPrice.ToString();
                cboBookPress.Text     = bkinfo.BookPress.ToString();
                dtpPublishDate.Text   = bkinfo.BookPublishDate.ToString();
                lblStorageInDate.Text = bkinfo.StorageInDate.ToString();
                txtStorageInNum.Value = bkinfo.StorageInNum;
                lblInventoryNum.Value = bkinfo.InventoryNum;
                lblBorrowedNum.Value  = bkinfo.BorrowedNum;
                //把文本转成图片
                if (string.IsNullOrWhiteSpace(bkinfo.BookImage))
                {
                    pbCurrentImage.Image = null;
                }
                else
                {
                    pbCurrentImage.Image = (Image)SerializeObjectToString.DeserializeObject(bkinfo.BookImage);
                }
                //处理下拉框
                cboBookPress.SelectedItem = presslist.Find(x => x.PressId == bkinfo.BookPress);
                //得到当前书类别信息
                BookTypeExtModel currenttype = btbll.GetBookTypeId(bkinfo.BookType);
                BookTypeModel    typeone     = typelist.Find(x => x.TypeId == currenttype.ParentTypeId);
                cboBookTypeOne.SelectedItem = typeone;
            }
        }