Example #1
0
        public List <Product> GetAllProducts()
        {
            List <Product> elements = new List <Product>();
            string         sql      = "select * from TF_Product";
            DataTable      dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Product element = new Product();
                    element.ID = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.种类 = ProductTypeLogic.GetInstance().GetProductType(Convert.ToInt32(dt.Rows[i]["种类"]));
                    element.品名 = dt.Rows[i]["品名"].ToString();
                    element.单位 = dt.Rows[i]["单位"].ToString();
                    element.进价 = Convert.ToDecimal(dt.Rows[i]["进价"]);
                    element.售价 = Convert.ToDecimal(dt.Rows[i]["售价"]);
                    element.厂家 = dt.Rows[i]["厂家"].ToString();
                    element.姓名 = dt.Rows[i]["姓名"].ToString();
                    element.电话 = dt.Rows[i]["电话"].ToString();
                    element.地址 = dt.Rows[i]["地址"].ToString();
                    element.备注 = dt.Rows[i]["备注"].ToString();
                    elements.Add(element);
                }
            }
            return(elements);
        }
Example #2
0
        private void LoadProductTypes()
        {
            List <ProductType> elements = ProductTypeLogic.GetInstance().GetAllProductTypes();

            comboBox1.Items.Clear();
            foreach (ProductType element in elements)
            {
                comboBox1.Items.Add(element);
            }
            dataGridView1.DataSource = ProductTypeLogic.GetInstance().GetProductTypes(string.Empty);
        }
Example #3
0
        private void LoadProductTypes()
        {
            List <ProductType> elements = ProductTypeLogic.GetInstance().GetAllProductTypes();

            comboBox2.Items.Clear();
            comboBox2.Items.Add("--不限--");
            foreach (ProductType element in elements)
            {
                comboBox2.Items.Add(element);
            }
            comboBox2.SelectedIndex = 0;
        }
Example #4
0
        private DataTable Search(string name = null, int flag = 0)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name) && name.Trim() != "")
            {
                nm = " and 类型 like '%" + name + "%'";
            }
            string jy = "";

            if (flag > 0)
            {
                jy = " and Flag=" + flag;
            }
            string where = "(1=1)" + nm + jy;
            return(ProductTypeLogic.GetInstance().GetProductTypes(where));
        }
Example #5
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         if (MessageBox.Show("确定要删除该产品类型?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             ProductType productType = (ProductType)comboBox1.SelectedItem;
             if (ProductTypeLogic.GetInstance().DeleteProductType(productType))
             {
                 LoadProductTypes();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的产品类型!");
     }
 }
Example #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         ProductType productType = (ProductType)comboBox1.SelectedItem;
         productType.类型   = textBox1.Text.Trim();
         productType.备注   = textBox2.Text.Trim();
         productType.Flag = checkBox1.Checked;
         ProductTypeLogic al = ProductTypeLogic.GetInstance();
         if (al.ExistsNameOther(productType.类型, productType.ID))
         {
             if (MessageBox.Show("系统中已经存在该产品类型,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (al.UpdateProductType(productType))
                 {
                     LoadProductTypes();
                     MessageBox.Show("修改成功!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (al.UpdateProductType(productType))
             {
                 LoadProductTypes();
                 MessageBox.Show("修改成功!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的产品类型!");
     }
 }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            ProductType productType = new ProductType();

            productType.类型   = textBox1.Text.Trim();
            productType.备注   = textBox2.Text.Trim();
            productType.Flag = checkBox1.Checked;
            ProductTypeLogic al = ProductTypeLogic.GetInstance();

            if (al.ExistsName(productType.类型))
            {
                if (MessageBox.Show("系统中已经存在该产品类型,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = al.AddProductType(productType);
                    if (id > 0)
                    {
                        productType.ID = id;
                        LoadProductTypes();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = al.AddProductType(productType);
                if (id > 0)
                {
                    productType.ID = id;
                    LoadProductTypes();
                    MessageBox.Show("添加成功!");
                }
            }
        }
Example #8
0
        public Product GetProduct(int id)
        {
            string    sql = "select * from TF_Product where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                Product element = new Product();
                element.ID = id;
                element.品名 = dt.Rows[0]["品名"].ToString();
                element.种类 = ProductTypeLogic.GetInstance().GetProductType(Convert.ToInt32(dt.Rows[0]["种类"]));
                element.单位 = dt.Rows[0]["单位"].ToString();
                element.进价 = Convert.ToDecimal(dt.Rows[0]["进价"]);
                element.售价 = Convert.ToDecimal(dt.Rows[0]["售价"]);
                element.厂家 = dt.Rows[0]["厂家"].ToString();
                element.姓名 = dt.Rows[0]["姓名"].ToString();
                element.电话 = dt.Rows[0]["电话"].ToString();
                element.地址 = dt.Rows[0]["地址"].ToString();
                element.备注 = dt.Rows[0]["备注"].ToString();
                return(element);
            }
            return(null);
        }