private void btn_Add_Click(object sender, EventArgs e)
        {
            Norm   user  = new Norm();
            string _name = txt_Name.Text.Trim();

            if (!ValidateService.IsNumber(_name))   // 项目 Common 的 ValidateService 类
            {
                MessageBox.Show("必须为数字!");
                txt_Name.Focus();
                return;
            }
            if (user.Exists(_name))
            {
                MessageBox.Show("该规格已存在!");
                txt_Name.Focus();
                return;
            }

            user.NormName = _name;
            int re = user.Add();

            if (re > 0)
            {
                MessageBox.Show("添加成功!");
                txt_Name.Text = "";
                txt_Name.Focus();
                BindDGV();
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
示例#2
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            Norm user = new Norm();

            string _name = txt_Name.Text.Trim();
            if (!ValidateService.IsNumber(_name))
            {
                MessageBox.Show("必须为数字!");
                txt_Name.Focus();
                return;
            }
            if (user.Exists(_name))
            {
                MessageBox.Show("该规格已存在!");
                txt_Name.Focus();
                return;
            }
            user.NormName = _name;
            int re = user.Add();
            if (re > 0)
            {
                MessageBox.Show("添加成功!");
                txt_Name.Text = "";
                txt_Name.Focus();
                BindDGV();
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
示例#3
0
        private void BindNorm()
        {
            Norm    n  = new Norm();
            DataSet ds = n.GetList("");

            if (ds != null)
            {
                cbx_Norm.DataSource    = ds.Tables[0];
                cbx_Norm.DisplayMember = "NormName";
                cbx_Norm.ValueMember   = "NormName";
            }
            else
            {
                MessageBox.Show("请先设置产品规格!");
                btn_Add.Enabled = false;
            }
        }
 /// <summary>
 /// 点击单元格的内容时发生
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index)
     {
         if (MessageBox.Show(this, "确定要删除吗?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value;
             if (v != null)
             {
                 Norm no = new Norm();
                 if (no.IsRelation(v.ToString()))
                 {
                     MessageBox.Show("该记录已被使用,禁止删除!");
                     return;
                 }
                 bool re = no.Delete(v.ToString());
                 if (re)
                 {
                     MessageBox.Show("删除成功!");
                     BindDGV();
                 }
                 else
                 {
                     MessageBox.Show("删除失败!");
                 }
             }
         }
     }
     else if (e.ColumnIndex == dataGridView1.Columns["cModity"].Index)
     {
         object v = dataGridView1.Rows[e.RowIndex].Cells["cID"].Value;
         if (ValidateService.IsNumber(v))
         {
             Norm no = new Norm();
             no.GetModel((int)v);
             frmGoodsNormUpdate f = new frmGoodsNormUpdate(no);
             f.ShowDialog();
             if (f._isTrue)
             {
                 BindDGV();
             }
         }
     }
 }
示例#5
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index)
     {
         if (MessageBox.Show(this, "确定要删除吗?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value;
             if (v!=null)
             {
                 Norm no = new Norm();
                 if (no.IsRelation(v.ToString()))
                 {
                     MessageBox.Show("该记录已被使用,禁止删除!");
                     return;
                 }
                 bool re = no.Delete(v.ToString());
                 if (re)
                 {
                     MessageBox.Show("删除成功!");
                     BindDGV();
                 }
                 else
                 {
                     MessageBox.Show("删除失败!");
                 }
             }
         }
     }
     else if (e.ColumnIndex == dataGridView1.Columns["cModity"].Index)
     {
         object v = dataGridView1.Rows[e.RowIndex].Cells["cID"].Value;
         if (ValidateService.IsNumber(v))
         {
             Norm no = new Norm();
             no.GetModel((int)v);
             frmGoodsNormUpdate f = new frmGoodsNormUpdate(no);
             f.ShowDialog();
             if (f._isTrue)
             {
                 BindDGV();
             }
         }
     }
 }
示例#6
0
 public frmGoodsNormUpdate(Norm m)
 {
     InitializeComponent();
     this._model = m;
 }
示例#7
0
 public frmGoodsNormUpdate(Norm m)
 {
     InitializeComponent();
     this._model = m;
 }
        /// <summary>
        /// 获取 dataGridView 的数据
        /// </summary>
        private void BindDGV()
        {
            DataSet ds = new Norm().GetList("");

            dataGridView1.DataSource = ds.Tables[0];
        }
示例#9
0
 private void BindDGV()
 {
     DataSet ds = new Norm().GetList("");
     dataGridView1.DataSource = ds.Tables[0];
 }