Exemple #1
0
        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 DuyetGridView2()
 {
     foreach (DataGridViewRow dr in dataGridViewX2.Rows)
     {
         String s2 = dr.Cells["Cl_msp"].Value.ToString();
         int    s4 = int.Parse(dr.Cells["Cl_soluong"].Value.ToString());
         SP     sp = new SP(s2, s4);
         hd.AddSP(sp);
     }
 }