コード例 #1
0
        private void 修改名称ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (添加下级产品 mForm = new 添加下级产品())
            {
                mForm.Text = "修改采购物品分类名称";
                mForm.txtProductName.Text = tvDaGoodsType.SelectedNode.Text;
                if (DialogResult.Yes == mForm.ShowDialog())
                {
                    string newName = mForm.txtProductName.Text.Trim();

                    myEntity.DaGoodsTypes.Where(d => d.IntID == Convert.ToInt32(tvDaGoodsType.SelectedNode.Name.Replace("tvGoodsType", ""))).SingleOrDefault().VcType = newName;

                    int ret = myEntity.SaveChanges();
                    if (ret > 0)
                    {
                        MessageBox.Show("修改成功");
                        AddTree();
                    }
                    else
                    {
                        MessageBox.Show("修改失败");
                    }
                }
            }
        }
コード例 #2
0
        private void 添加toolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (添加下级产品 mForm = new 添加下级产品())
            {
                mForm.Text = "采购物品分类名称";
                mForm.txtProductName.Text = tvDaGoodsType.SelectedNode.Text;
                if (DialogResult.Yes == mForm.ShowDialog())
                {
                    string newName = mForm.txtProductName.Text.Trim();

                    DaGoodsType mDaGoodsType = new DaGoodsType()
                    {
                        IntParentID = Convert.ToInt32(tvDaGoodsType.SelectedNode.Name.Replace("tvGoodsType", "")), VcType = newName, IntEmpNum = Classes.PubClass.UserId
                    };


                    myEntity.DaGoodsTypes.Add(mDaGoodsType);

                    int ret = myEntity.SaveChanges();
                    if (ret > 0)
                    {
                        MessageBox.Show("增加成功");
                        AddTree();
                    }
                    else
                    {
                        MessageBox.Show("增加失败");
                    }
                }
            }
        }