private void buttonX_add_Click(object sender, EventArgs e) { if (hd == null) { MessageBox.Show("Ban phai lap phieu mua truoc"); } else { hd.SetMKH(textBoxX_makh3.Text);// yes or no SP s = new SP(textBoxX_msp.Text, int.Parse(textBoxX_soluong.Text)); if (s.GetStatus() == 0) //san pham la ok { SP sp = hd.AddSP(s); //them moi san pham !! kiem tra san pham bi trungs HienthiCTmuahang(); DataRow dr = DtableMuahang.NewRow(); dr["msp"] = sp.GetMSP(); dr["tensp"] = sp.GetMSP(); dr["gia"] = sp.GetGiaban(); dr["sl"] = sp.GetSoluong();// textBoxX_soluong.Text;//Int32.Parse(textBoxX_sl.Text.ToString()); dr["thanhtien"] = sp.GetThanhtien(); DtableMuahang.Rows.Add(dr); deleteRow(dataGridViewX1, "ColumnMsp"); } } }
private void dataGridViewX1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridViewRow dr = new DataGridViewRow(); dr = dataGridViewX1.Rows[e.RowIndex]; mdh = dr.Cells[0].Value.ToString(); hienthiCTdathang(mdh); String s2 = dr.Cells[1].Value.ToString(); String s3 = dr.Cells[2].Value.ToString(); hd.SetMKH(s2); hd.SetMNV(s3); DuyetGridView2(); }