예제 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (CheckTextBox())
            {
                var proi = new ProductInfo();
                proi.ProCost  = Convert.ToDecimal(txtCost.Text);
                proi.ProName  = txtName.Text;
                proi.ProNum   = txtNum.Text;
                proi.ProPrice = Convert.ToDecimal(txtPrice.Text);
                proi.ProSpell = txtSpell.Text;
                proi.ProStock = Convert.ToDecimal(txtStock.Text);
                proi.ProUnit  = txtUnit.Text;
                proi.Remark   = txtRemark.Text;
                proi.CatId    = Convert.ToInt32(cmbCategory.SelectedValue);

                if (_tp == 1)//新增
                {
                    proi.DelFlag = 0;
                    proi.SubTime = DateTime.Now;
                    proi.SubBy   = 1;
                }
                else if (_tp == 2)//修改
                {
                    proi.ProId = Convert.ToInt32(labId.Text);
                }

                var proiBLL = new ProductInfoBLL();
                var msg     = proiBLL.SaveProductInfo(_tp, proi) ? "操作成功" : "操作失败";
                MessageBox.Show(msg);
                this.Close();
            }
        }
예제 #2
0
 //新增和修改产品
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (CheckEmpty())
     {
         ProductInfo pro = new ProductInfo();
         pro.CatId    = Convert.ToInt32(cmbCategory.SelectedValue);
         pro.ProCost  = Convert.ToDecimal(txtCost.Text);
         pro.ProName  = txtName.Text;
         pro.ProNum   = txtNum.Text;
         pro.ProPrice = Convert.ToDecimal(txtPrice.Text);
         pro.ProSpell = txtSpell.Text;
         pro.ProStock = Convert.ToDecimal(txtStock.Text);
         pro.ProUnit  = txtUnit.Text;
         pro.Remark   = txtRemark.Text;
         if (this.Tp == 3)//新增
         {
             pro.DelFlag = 0;
             pro.SubBy   = 1;
             pro.SubTime = System.DateTime.Now;
         }
         else if (this.Tp == 4)//修改
         {
             pro.ProId = Convert.ToInt32(labId.Text);
         }
         ProductInfoBLL bll = new ProductInfoBLL();
         string         msg = bll.SaveProduct(pro, this.Tp) ? "操作成功" : "操作失败";
         MessageBox.Show(msg);
         this.Close();
     }
 }
예제 #3
0
        private void btnDeleteCategory_Click(object sender, EventArgs e)
        {
            CategoryInfoBLL bll = new CategoryInfoBLL();

            if (dgvCategory.SelectedRows.Count <= 0)
            {
                msg.MsgDivShow("请选择要删除的项", 1);
                return;
            }
            if (MessageBox.Show("确定删除该产品吗?", "删除商品", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {
                int            id   = ((CategoryInfo)dgvCategory.SelectedRows[0].DataBoundItem).CId;
                ProductInfoBLL pbll = new ProductInfoBLL();
                if (pbll.GetProCountByCId(id) > 0)
                {
                    msg.MsgDivShow("该类别下有很多商品部能删除", 1);
                    return;
                }
                string strMsg = bll.SoftDeleteCategoryInfo(id) ? "删除成功" : "删除失败";
                msg.MsgDivShow(strMsg, 1);
                LoadCategoryInfoByDelFlag(0);
            }
            else
            {
                msg.MsgDivShow("您已经取消删除", 1);
            }
        }
예제 #4
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            ArrayList      pkArray = null;
            ProductInfoBLL bll     = null;

            try
            {
                bll = BLLFactory.CreateBLL <ProductInfoBLL>();

                pkArray = GvHelper.GetPKValueByChk(this.GvList, 0, "cbxSelect", 0);

                foreach (object key in pkArray)
                {
                    if (!bll.HasProducePlan(key.ToString()))
                    {
                        bll.DeleteProductInfo(new ProductInfo {
                            PID = key.ToString()
                        });
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "myjs", "alert('选中的产品被产品计划使用过,不能被删除');", true);
                    }
                }

                this.BindData();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        private void BindData()
        {
            ProductInfoBLL bll       = null;
            DataPage       dp        = new DataPage();
            ProductInfo    condition = new ProductInfo();

            try
            {
                bll             = BLLFactory.CreateBLL <ProductInfoBLL>();
                condition.PCODE = this.PCODE.Text;
                condition.PNAME = this.PNAME.Text;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <ProductInfo> list = dp.Result as List <ProductInfo>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["PID"].ToString());

                    (this.GvList.Rows[i].Cells[7].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            ProductInfo    info = new ProductInfo();
            ProductInfoBLL bll  = null;

            try
            {
                UIBindHelper.BindModelByControls(this.Page, info);

                bll = BLLFactory.CreateBLL <ProductInfoBLL>();

                if (this.hiID.Value == "")
                {
                    bll.Insert(info);
                }
                else
                {
                    info.CREATEUSER = this.HiCREATEUSER.Value;
                    info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value);
                    info.PID        = this.hiID.Value;
                    bll.Update(info);
                }

                ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.refreshData();parent.closeAppWindow1();", true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
        private void BindData()
        {
            string         id   = Request.QueryString["id"];
            ProductInfoBLL bll  = null;
            ProductInfo    info = new ProductInfo();

            try
            {
                bll = BLLFactory.CreateBLL <ProductInfoBLL>();
                if (string.IsNullOrEmpty(id) == false)
                {
                    info.PID = id;
                    info     = bll.Get(info);

                    UIBindHelper.BindForm(this.Page, info);
                    this.hiID.Value         = info.PID;
                    this.HiCREATEUSER.Value = info.CREATEUSER;
                    this.HiCREATETIME.Value = info.CREATETIME.ToString();
                }
                else
                {
                    info = new ProductInfo();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        //加载所有产品
        private void LoadProductInfoByDelFlag(int p)
        {
            ProductInfoBLL bll = new ProductInfoBLL();

            dgvProduct.AutoGenerateColumns      = false; //禁止自动生成列
            dgvProduct.DataSource               = bll.GetAllProductInfoByDelFlag(p);
            dgvProduct.SelectedRows[0].Selected = false; //默认第一行不选中
        }
예제 #9
0
        //加载所有产品
        private void LoadProductInfoByDelFlag(int delFlag)
        {
            ProductInfoBLL bll = new ProductInfoBLL();

            dgvProductInfo.AutoGenerateColumns      = false;
            dgvProductInfo.DataSource               = bll.GetAllProductInfoByDelFlag(delFlag);
            dgvProductInfo.SelectedRows[0].Selected = false;
        }
예제 #10
0
        //g根据类别id获取对应类别下面的产品

        //加载所有的商品
        private void LoadAllProductInfoByDelFlag(int p)
        {
            ProductInfoBLL probll = new ProductInfoBLL();

            dgvProduct.AutoGenerateColumns = false;//禁止自动生成列
            dgvProduct.DataSource          = probll.GetAllProductInfoByFlag(p);
            dgvProduct.ClearSelection();
        }
예제 #11
0
        private void LoadCnode(TreeNodeCollection tnc, int cId)
        {
            List <ProductInfo> pros = new ProductInfoBLL().GetAliveProductInfosByCid(cId);

            foreach (ProductInfo pro in pros)
            {
                tnc.Add(pro.ProName + ":" + pro.ProPrice + "元");
            }
        }
예제 #12
0
        private void LoadProductInfoByCatId(int catId, TreeNodeCollection nodes)
        {
            var bll       = new ProductInfoBLL();
            var listProds = bll.GetProductInfoByCatId(catId);

            foreach (var pro in listProds)
            {
                nodes.Add(pro.ProName + "===" + pro.ProPrice + "元");
            }
        }
예제 #13
0
        //根据商品类别id查找该类别下所有的产品,并加载出来
        private void LoadProduct(int p, TreeNodeCollection tnc)
        {
            ProductInfoBLL     bll  = new ProductInfoBLL();
            List <ProductInfo> list = bll.GetProductInfoByCatId(p);

            foreach (ProductInfo item in list)
            {
                tnc.Add(item.ProName + "====" + item.ProPrice + "元");
            }
        }
예제 #14
0
        private void BindProductInfoList()
        {
            ProductInfoBLL     bll   = null;
            List <ProductInfo> array = null;

            bll   = BLLFactory.CreateBLL <ProductInfoBLL>();
            array = bll.GetList();

            this.PRODUCTIONID.DataSource = array;
            this.PRODUCTIONID.DataBind();
        }
예제 #15
0
        /// <summary>
        /// 加载所有产品
        /// </summary>
        /// <param name="v"></param>
        private void LoadProductInfoByDelFlag(int v)
        {
            ProductInfoBLL bll = new ProductInfoBLL();

            dgvProductInfo.AutoGenerateColumns = false;//禁止自动生产列
            dgvProductInfo.DataSource          = bll.GetAllProductInfoByDelFlag(v);
            if (dgvProductInfo.Rows.Count > 0)
            {
                dgvProductInfo.SelectedRows[0].Selected = false;//禁止默认第一行选中
            }
        }
예제 #16
0
        public ActionResult ProductList()
        {
            ProductInfoBLL bll = new ProductInfoBLL();

            var page = new PageDTO()
            {
                PageIndex = PageNo, PageSize = DefaultPageSize
            };

            var result = bll.GetProductTemps(CurrentUser.SupplierID, LanguageEnum.TraditionalChinese, page);

            return(View(result));
        }
예제 #17
0
        //删除产品
        private void btnDeletePro_Click(object sender, EventArgs e)
        {
            if (dgvProductInfo.SelectedRows.Count > 0)
            {
                //获取当前选中行的 ID
                int id = Convert.ToInt32(dgvProductInfo.SelectedRows[0].Cells[0].Value.ToString());

                ProductInfoBLL bll = new ProductInfoBLL();
                string         msg = bll.SoftDeleteProductInfoProId(id) ? "操作成功" : "操作失败";
                MessageBox.Show(msg);
                LoadProductInfoByDelFlag(0);//刷新
            }
        }
예제 #18
0
        private void BindProductInfoList()
        {
            List <DictInfo>    dicts = null;
            ProductInfoBLL     bll   = null;
            List <ProductInfo> array = null;

            bll   = BLLFactory.CreateBLL <ProductInfoBLL>();
            array = bll.GetList();

            dicts = array.Select(p => new DictInfo {
                ID = p.PID, Des = p.PNAME
            }).ToList <DictInfo>();
            Tools.BindDataToDDL(this.PRODUCTIONID, dicts, Tools.QueryDDLFirstItem);
        }
예제 #19
0
 //模糊搜索
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtSearch.Text))
     {
         ProductInfoBLL bll = new ProductInfoBLL();
         dgvProductInfo.AutoGenerateColumns = false;
         dgvProductInfo.DataSource          = bll.GetProductByProNum(txtSearch.Text);
         // dgvProductInfo.SelectedRows[0].Selected = false;
         // dgvProductInfo.AreAllCellsSelected(true);
     }
     else
     {
         LoadProductInfoByDelFlag(0);
     }
 }
예제 #20
0
 //修改产品
 private void btnUpdatePro_Click(object sender, EventArgs e)
 {
     if (dgvProductInfo.SelectedRows.Count > 0)
     {
         int id = Convert.ToInt32(dgvProductInfo.SelectedRows[0].Cells[0].Value.ToString());
         //根据id查选中行的所有数据
         ProductInfoBLL bll = new ProductInfoBLL();
         fea.obj = bll.GetProductInfoByProId(id);
         LoadFrmChangeProduct(4);
     }
     else
     {
         MessageBox.Show("请选中要修改的行");
     }
 }
예제 #21
0
 private void cmbCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbCategory.SelectedIndex == 0)
     {
         LoadProductInfoByDelFlag(0);//查询所有的产品
     }
     else
     {
         int id = Convert.ToInt32(cmbCategory.SelectedValue);
         //根据商品类别的id去产品的表中查询该类别下的所有的产品,重新绑定到dgvproduct上
         ProductInfoBLL bll = new ProductInfoBLL();
         dgvProductInfo.AutoGenerateColumns      = false;
         dgvProductInfo.DataSource               = bll.GetProductInfoByCatId(id);
         dgvProductInfo.SelectedRows[0].Selected = false;
     }
 }
예제 #22
0
 //修改产品  4--修改
 private void btnUpdatePro_Click(object sender, EventArgs e)
 {
     if (dgvProductInfo.SelectedRows.Count > 0)
     {
         //获取id
         //根据id查询该行数据是否真的存在
         //把对象传到另一个窗体---需要对象
         int            id  = Convert.ToInt32(dgvProductInfo.SelectedRows[0].Cells[0].Value);
         ProductInfoBLL bll = new ProductInfoBLL();
         ProductInfo    pro = bll.GetProductInfoByProId(id);
         if (pro != null)
         {
             fea.obj = pro;
             ShowFrmChangeProduct(4);
         }
     }
 }
예제 #23
0
 //删除产品
 private void btnDeletePro_Click(object sender, EventArgs e)
 {
     //是否选中
     if (dgvProductInfo.SelectedRows.Count > 0)
     {
         int id = Convert.ToInt32(dgvProductInfo.SelectedRows[0].Cells[0].Value);
         //根据id删除选中的行
         ProductInfoBLL bll = new ProductInfoBLL();
         string         msg = bll.DeleteProductById(id) ? "操作成功" : "操作失败";
         MessageBox.Show(msg);
         LoadProductInfoByDelFlag(0);
     }
     else
     {
         MessageBox.Show("请选中要删除的行!");
     }
 }
예제 #24
0
 private void cmbCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbCategory.SelectedIndex != 0)
     {
         ProductInfoBLL bll = new ProductInfoBLL();
         dgvProductInfo.AutoGenerateColumns = false;
         dgvProductInfo.DataSource          = bll.GetProductInfoByCatId(Convert.ToInt32(cmbCategory.SelectedValue));
         if (dgvProductInfo.Rows.Count > 0)
         {
             dgvProductInfo.SelectedRows[0].Selected = false;
         }
         else
         {
             LoadProductInfoByDelFlag(0);
         }
     }
 }
예제 #25
0
 private void cmbCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbCategory.SelectedIndex == 0)
     {
         LoadProductInfoByDelFlag(0);
     }
     else
     {
         int                id   = Convert.ToInt32(cmbCategory.SelectedValue);
         ProductInfoBLL     bll  = new ProductInfoBLL();
         List <ProductInfo> list = bll.GetProductInfoByCatId(id);
         if (list.Count > 0)
         {
             dgvProductInfo.AutoGenerateColumns      = false;
             dgvProductInfo.DataSource               = list;
             dgvProductInfo.SelectedRows[0].Selected = false;
         }
     }
 }
예제 #26
0
 private void btnUpdatePro_Click(object sender, EventArgs e)
 {
     if (dgvProductInfo.SelectedRows.Count > 0)
     {
         //获取要修改的产品的Id
         //根据id查询该行数据是否真的存在--要获取该行数据
         //把对象传到另一个窗体中---对象
         int            id  = Convert.ToInt32(dgvProductInfo.SelectedRows[0].Cells[0].Value);
         ProductInfoBLL bll = new ProductInfoBLL();
         ProductInfo    pro = bll.GetProductInfoByProId(id);
         pro.ProId = id;
         feas.obj  = pro;
         ShowFrmChangeProduct(2);
     }
     else
     {
         MessageBox.Show("请选择要操作的行");
     }
 }
예제 #27
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            int flag = 0;

            if (string.IsNullOrEmpty(txtSearch.Text))
            {
                LoadProductInfoByDelFlag(0);
                return;
            }
            else
            {
                flag = char.IsNumber(txtSearch.Text[0]) ? 2 : 1;
                var bll = new ProductInfoBLL();
                dgvProduct.DataSource = bll.GetProductInfoBySpellNum(txtSearch.Text, flag);
                if (dgvProduct.SelectedRows.Count > 0)
                {
                    dgvProduct.SelectedRows[0].Selected = false;
                }
            }
        }
예제 #28
0
 //修改菜
 private void btnUpdatePro_Click(object sender, EventArgs e)
 {
     //修改传4
     if (dgvProductInfo.SelectedRows.Count > 0)
     {
         //获取id,获取该id对象的数据
         string         strId = dgvProductInfo.SelectedRows[0].Cells[0].Value.ToString();
         int            id    = Convert.ToInt32(strId);
         ProductInfoBLL bll   = new ProductInfoBLL();
         ProductInfo    pro   = bll.GetProductByProId(id);
         pro.ProId = id;
         fea.Obj   = pro;//传对象
         //传对象
         ShowFrmChangeProduct(4);
     }
     else
     {
         MessageBox.Show("选中行");
     }
 }
예제 #29
0
        //搜索
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            ProductInfoBLL bll = new ProductInfoBLL();
            string         txt = txtSearch.Text;
            int            n   = 0;

            if (!string.IsNullOrEmpty(txt))
            {
                if (char.IsLetter(txt[0]))//是不是字母
                {
                    n = 2;
                }
                else//不是字母
                {
                    n = 1;
                }
            }
            dgvProduct.AutoGenerateColumns      = false;
            dgvProduct.DataSource               = bll.GetProductBySpellOrNum(txt, n);
            dgvProduct.SelectedRows[0].Selected = false;
        }
예제 #30
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!IsNotEmpty())
            {
                return;
            }
            ProductInfoBLL proBll = new ProductInfoBLL();
            ProductInfo    pro    = new ProductInfo();
            int            i      = 0;

            pro.CId      = Convert.ToInt32(cmbCategory.SelectedValue); //获取选择的类别
            pro.ProCost  = Convert.ToDouble(txtCost.Text);             //价格
            pro.ProName  = txtName.Text;                               //名字
            pro.ProNum   = txtNum.Text;                                //编号
            pro.ProPrice = Convert.ToDouble(txtPrice.Text);            //实际的价格
            pro.ProSpell = txtSpell.Text;                              //拼音
            pro.ProStock = Convert.ToInt32(txtStock.Text);
            pro.ProUnit  = txtUnit.Text;                               //单位
            pro.Remark   = txtRemark.Text;;                            //备注
            if (status == HandleStatus.Insert)
            {
                pro.DelFlag = 0;
                pro.SubBy   = 1;
                pro.SubTime = System.DateTime.Now;//当前时间

                i = proBll.add(pro);
            }
            if (status == HandleStatus.Update)
            {
                pro.ProId   = oldProduct.ProId;
                pro.DelFlag = oldProduct.DelFlag;
                pro.SubBy   = oldProduct.SubBy;
                pro.SubTime = oldProduct.SubTime;

                i = proBll.update(pro);
            }
            string msg = i > 0 ? "操作成功" : "操作失败";

            md.MsgDivShow(msg, 1, Bind);
        }