コード例 #1
0
        private void btn_AddPOGCID_Click(object sender, EventArgs e)
        {
            FrmGoodsCategory fgc = new FrmGoodsCategory();

            fgc.cmb = cmbox_POGCID;
            fgc.Show();
        }
コード例 #2
0
ファイル: FrmNEGoods.cs プロジェクト: wenfeifei/MarketMS
 private void btn_AddCategory_Click(object sender, EventArgs e)
 {
     Active = true;
     FrmGoodsCategory fgc = new FrmGoodsCategory();
     fgc.cmb = cmbox_GCID;
     fgc.Show();
 }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection myconn = BaseClass.DBConn.MyConn();

            myconn.Open();
            string       sql   = "select count(*) from tb_GoodsCategory where GCName=@gcname";
            MySqlCommand mycmd = new MySqlCommand(sql, myconn);

            mycmd.Parameters.Add("@gcname", MySqlDbType.VarChar, 20).Value = gcname;
            int n = Convert.ToInt32(mycmd.ExecuteScalar());

            if (n > 0)
            {
                //修改
                sql   = "update tb_GoodsCategory set GCName=@gcname where GCID=@gcid";
                mycmd = new MySqlCommand(sql, myconn);
                mycmd.Parameters.Add("@gcname", MySqlDbType.VarChar, 20).Value = txtbox_GCName.Text.Trim();
                mycmd.Parameters.Add("@gcid", MySqlDbType.Int32, 20).Value     = Convert.ToInt32(gcid);
                mycmd.ExecuteNonQuery();
                myconn.Close();

                FrmGoodsCategory fgc = (FrmGoodsCategory)this.Owner;//委托父窗体
                fgc.tvBindData();

                MessageBox.Show("类别'" + txtbox_GCName.Text + "'修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                sql   = "select count(*) from tb_GoodsCategory where GCName=@gcname";
                mycmd = new MySqlCommand(sql, myconn);
                mycmd.Parameters.Add("@gcname", MySqlDbType.VarChar, 20).Value = txtbox_GCName.Text;
                n = Convert.ToInt32(mycmd.ExecuteScalar());
                if (n > 0)
                {
                    MessageBox.Show("类别'" + txtbox_GCName.Text + "'已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtbox_GCName.Focus();
                }
                else
                {
                    //添加
                    sql   = "insert into tb_GoodsCategory(GCName) values(@gcname)";
                    mycmd = new MySqlCommand(sql, myconn);
                    mycmd.Parameters.Add("@gcname", MySqlDbType.VarChar, 20).Value = txtbox_GCName.Text.Trim();
                    mycmd.ExecuteNonQuery();
                    myconn.Close();

                    FrmGoodsCategory fgc = (FrmGoodsCategory)this.Owner;//委托父窗体
                    fgc.tvBindData();

                    MessageBox.Show("类别'" + txtbox_GCName.Text + "'添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
        }
コード例 #4
0
        private void tsbtn_Category_Click(object sender, EventArgs e)
        {
            FrmGoodsCategory fgc = new FrmGoodsCategory();

            fgc.Show();
        }