Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public bool ThemBaoCao(Baocaochi_DTO bc)
        {
            SqlConnection conn1 = ConnectToSQL.HamKetNoi();
            string        str1  = "INSERT INTO BAOCAOCHI(Ngay, Loai, Tien) VALUES (@Ngay, @Loai, @Tien)";
            SqlCommand    cmd1  = new SqlCommand(str1, conn1);

            cmd1.CommandType = CommandType.Text;

            cmd1.Parameters.Add("@Ngay", SqlDbType.DateTime);
            cmd1.Parameters.Add("@Loai", SqlDbType.NVarChar, 50);
            cmd1.Parameters.Add("@Tien", SqlDbType.Float);

            cmd1.Parameters["@Ngay"].Value = bc.Ngay;
            cmd1.Parameters["@Loai"].Value = bc.Loai;
            cmd1.Parameters["@Tien"].Value = bc.Tien;

            conn1.Open();
            cmd1.ExecuteNonQuery();
            conn1.Close();
            return(true);
        }
Пример #4
0
        public bool ThemBaoCao(Baocaochi_DTO bc)
        {
            Baocaochi_DAO t = new Baocaochi_DAO();

            return(t.ThemBaoCao(bc));
        }