示例#1
0
        public static PropertyLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new PropertyLogic();
            }

            return(instance);
        }
示例#2
0
 private void LoadPropertys()
 {
     List<Property> ps = PropertyLogic.GetInstance().GetAllPropertys();
     comboBox2.Items.Clear();
     foreach (Property p in ps)
     {
         comboBox2.Items.Add(p);
     }
 }
示例#3
0
        private void LoadPropertys()
        {
            List <Property> elements = PropertyLogic.GetInstance().GetAllPropertys();

            comboBox1.Items.Clear();
            foreach (Property element in elements)
            {
                comboBox1.Items.Add(element);
            }
        }
示例#4
0
        private void LoadPropertys()
        {
            List <Property> elements = PropertyLogic.GetInstance().GetAllPropertys();

            comboBox1.Items.Clear();
            foreach (Property element in elements)
            {
                comboBox1.Items.Add(element);
            }
            dataGridView1.DataSource = PropertyLogic.GetInstance().GetPropertys(string.Empty);
        }
示例#5
0
 private DataTable Search(string name, string 用途 = null)
 {
     if (!string.IsNullOrEmpty(name))
     {
         string cj = "";
         if (!string.IsNullOrEmpty(用途))
         {
             cj = " and 用途 like '%" + 用途 + "%'";
         }
         string where = "名称 like '%" + name + "%'" + cj + " order by ID desc";
         return(PropertyLogic.GetInstance().GetPropertys(where));
     }
     return(null);
 }
示例#6
0
        private DataTable Search(string name, string 用途)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name))
            {
                nm = " and 名称 like '%" + name + "%'";
            }
            string cj = "";

            if (!string.IsNullOrEmpty(用途))
            {
                cj = " and 用途 like '%" + 用途 + "%'";
            }
            string where = "(1=1)" + nm + cj;
            return(PropertyLogic.GetInstance().GetPropertys(where));
        }
示例#7
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)
         {
             Property property = (Property)comboBox1.SelectedItem;
             if (PropertyLogic.GetInstance().DeleteProperty(property))
             {
                 LoadPropertys();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的资产!");
     }
 }
示例#8
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         Property property = (Property)comboBox1.SelectedItem;
         property.称  = textBox1.Text.Trim();
         property.单位 = textBox2.Text.Trim();
         property.用途 = textBox3.Text.Trim();
         property.价格 = numericUpDown1.Value;
         property.备注 = textBox4.Text.Trim();
         PropertyLogic pl = PropertyLogic.GetInstance();
         if (pl.ExistsNameOther(property.称, property.ID))
         {
             if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (pl.UpdateProperty(property))
                 {
                     LoadPropertys();
                     MessageBox.Show("修改成功!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (pl.UpdateProperty(property))
             {
                 LoadPropertys();
                 MessageBox.Show("修改成功!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的产品!");
     }
 }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            Property property = new Property();

            property.称  = textBox1.Text.Trim();
            property.单位 = textBox2.Text.Trim();
            property.用途 = textBox3.Text.Trim();
            property.价格 = numericUpDown1.Value;
            property.备注 = textBox4.Text.Trim();
            PropertyLogic pl = PropertyLogic.GetInstance();

            if (pl.ExistsName(property.称))
            {
                if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = pl.AddProperty(property);
                    if (id > 0)
                    {
                        property.ID = id;
                        LoadPropertys();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = pl.AddProperty(property);
                if (id > 0)
                {
                    property.ID = id;
                    LoadPropertys();
                    MessageBox.Show("添加成功!");
                }
            }
        }