private void btnThemThietBi_Click(object sender, EventArgs e) { //lay du lieu tu form string id = txtID.Text; string ten = txtTen.Text; float dongia = float.Parse(txtDonGia.Text); int soluong = int.Parse(txtSoLuong.Text); //thao tac them CSVC_DTO csvc = new CSVC_DTO(id, ten, dongia, soluong); CSVC_BUS t = new CSVC_BUS(); if (!t.ThemCSVC(csvc)) { MessageBox.Show("Thêm không thành công. Vui lòng thử lại!"); } //hien thi lai danh sach dgvDSThietBi.DataSource = t.LoadCSVC(); bingding(); //them vao bao cao chi DateTime ngay = DateTime.Now.Date; Baocaochi_DTO bc = new Baocaochi_DTO(ngay, "Thiet bi", float.Parse(txtDonGia.Text) * int.Parse(txtSoLuong.Text)); Baocaochi_BUS baocaochi = new Baocaochi_BUS(); baocaochi.ThemBaoCao(bc); }
private void QLBaoCao_Load(object sender, EventArgs e) { //chao labelChao.Text = DangNhap._manhanvien; //load ds thu theo ngay Baocaothu_BUS t = new Baocaothu_BUS(); dataGridViewBaoCaoThu.DataSource = t.LoadDS(DateTime.Parse(dateTimePickerNgay.Text)); //tinh tong thu int dong = dataGridViewBaoCaoThu.RowCount; float kq = 0; for (int i = 0; i < dong; i++) { kq += float.Parse(dataGridViewBaoCaoThu.Rows[i].Cells[2].Value.ToString()); } labelTongThu.Text = kq.ToString(); //load ds chi theo ngay Baocaochi_BUS t1 = new Baocaochi_BUS(); dataGridViewChi.DataSource = t1.LoadDS(DateTime.Parse(dateTimePickerNgay.Text)); //tinh tong chi int dong1 = dataGridViewChi.RowCount; float kq1 = 0; for (int i = 0; i < dong1; i++) { kq1 += float.Parse(dataGridViewChi.Rows[i].Cells[2].Value.ToString()); } labelTongChi.Text = kq1.ToString(); //load nv (ten, chucvu, chisoluong) NhanVien_BUS nhanvien = new NhanVien_BUS(); dataGridViewLuongNhanVien.DataSource = nhanvien.LoadDSLuong(); //tinh tong luong int dong2 = dataGridViewLuongNhanVien.RowCount; float kq2 = 0; for (int i = 0; i < dong2; i++) { kq2 += (float.Parse(dataGridViewLuongNhanVien.Rows[i].Cells[2].Value.ToString()) * 2000); } labelTongLuong.Text = kq2.ToString(); //du lieu tinh loi nhuan labelThu.Text = labelTongThu.Text; labelChi.Text = labelTongChi.Text; labelLuong.Text = labelTongLuong.Text; //loi nhuan labelLoiNhuan.Text = (float.Parse(labelThu.Text) - float.Parse(labelChi.Text) - float.Parse(labelLuong.Text)).ToString(); }
private void btnThem_Click(object sender, EventArgs e) { string id = ""; string ten = ""; float dongia = 0; int soluong = 0; //kiem tra if (txtIDThem.Text == "" || txtTenThem.Text == "" || txtDonGiaThem.Text == "" || txtSoLuongThem.Text == "") { MessageBox.Show("Bạn chưa nhập đủ dữ liệu!"); } //lay du lieu tu form else { id = txtIDThem.Text; ten = txtTenThem.Text; dongia = float.Parse(txtDonGiaThem.Text); soluong = int.Parse(txtSoLuongThem.Text); //thao tac them HangHoa_DTO hh = new HangHoa_DTO(id, ten, dongia, soluong); HangHoa_BUS t = new HangHoa_BUS(); if (!t.ThemHangHoa(hh)) { MessageBox.Show("Thêm không thành công. Vui lòng thử lại!."); } //hien thi lai form dgvThem.DataSource = t.LoadHangHoa(); //hien thi lai tab ds dgvDS.DataSource = t.LoadHangHoa(); //hien thi lai tab xoa dgvXoa.DataSource = t.LoadHangHoa(); bingdingXoa(); //hien thi lai tab sua dgvSua.DataSource = t.LoadHangHoa(); bingdingSua(); //them vao bao cao chi DateTime ngay = DateTime.Now.Date; Baocaochi_DTO bc = new Baocaochi_DTO(ngay, "Hang hoa", float.Parse(txtDonGiaThem.Text) * int.Parse(txtSoLuongThem.Text)); Baocaochi_BUS baocaochi = new Baocaochi_BUS(); baocaochi.ThemBaoCao(bc); } }