示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if ((bool)row.Cells["Chọn"].Value)
                {
                    dsDv += "," + row.Cells["ID Dịch Vụ"].Value.ToString();
                }
                //More code here
            }

            PhongBUS           phongBus = new PhongBUS();
            PhongDangSuDungDTO p        = phongBus.LayThongTinPhongDangSuDung(idPhong);

            int s;

            if (p.GiaDichVu == "")
            {
                s = 0;
            }
            else
            {
                s = Int32.Parse(p.GiaDichVu);
            }
            p.GiaDichVu = (s + tongChiPhi).ToString();

            p.DsDichVu += dsDv;
            // string str = p.ThoiGianBatDau.ToString("mm/dd/yyyy");
            phongBus.CapNhatThongTinPhongDangSuDung(p);
            // Observer Pattern
            TrangChu op = new TrangChu();

            op.onSubmit(dsDv, tongChiPhi, idPhong);
            this.Close();
            op.Show();
            //
        }
示例#2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Control control = sender as Control;
            string  ds      = "";
            //  _phongBUS
            PhongDangSuDungDTO _pdsdDTO = _phongBUS.LayThongTinPhongDangSuDung(idPhongClick);
            int index = _pdsdDTO.DsDichVu.IndexOf(control.Name.ToString());

            // MessageBox.Show(index.ToString());
            string[] array      = _pdsdDTO.DsDichVu.Split(',');
            var      listString = new List <string>(array);

            foreach (var item in listString)
            {
                if (item == control.Name)
                {
                    listString.Remove(item);
                    DichVuBUS dvBus = new DichVuBUS();
                    DichVuDTO dvDTO = dvBus.LayThongTinDichVu(item);
                    _pdsdDTO.GiaDichVu = (Int32.Parse(_pdsdDTO.GiaDichVu) - (int)dvDTO.Gia).ToString();
                    break;
                }
            }
            foreach (var item in listString)
            {
                ds += "," + item.ToString();
            }
            if (ds != "")
            {
                ds = ds.Remove(0, 1);
            }
            _pdsdDTO.DsDichVu = ds;
            _phongBUS.CapNhatThongTinPhongDangSuDung(_pdsdDTO);
            LoadDichDvu(_pdsdDTO.DsDichVu);

            CreateLableChiPhi();
        }