示例#1
0
        public static int themThongTinHangNhap(ThongTinHangNhapDTO ttNhap)
        {
            DbCommand command = DataAccessCode.CreateCommand();

            //// create a new parameter
            DbParameter param = command.CreateParameter();

            command.CommandText = "dbo.themThongTinHangNhap";
            param.ParameterName = "@ngayNhap";
            param.Value         = ttNhap.NgayNhap;
            param.DbType        = DbType.DateTime;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@maKhoHang";
            param.Value         = ttNhap.KhoHang.MaKhoHang;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            int kq = DataAccessCode.ExecuteNonQuery(command);

            if (kq == 1)
            {
                for (int i = 0; i < ttNhap.ChiTietHangNhap.Count; i++)
                {
                    ((ChiTietHangNhapDTO)ttNhap.ChiTietHangNhap[i]).MaThongTinHangNhap = layMaThongTinHangNhap(ttNhap.NgayNhap, ttNhap.KhoHang.MaKhoHang);

                    themChiTietHangNhap((ChiTietHangNhapDTO)ttNhap.ChiTietHangNhap[i]);
                }
            }
            return(1);
        }
        private void dongGoiChiTietHangNhapDTO(ThongTinHangNhapDTO dto)
        {
            for (int i = 0; i < grid_chiTietPhieuDat.RowCount; i++)
            {
                ChiTietHangNhapDTO chiTiet = new ChiTietHangNhapDTO();
                chiTiet.NhaCungCap = (NhaCungCapDTO)grid_chiTietPhieuDat.Rows[i].Cells["gridCTPhieuDatHang_cNCC"].Value;
                chiTiet.NguyenLieu = (NguyenLieuDTO)grid_chiTietPhieuDat.Rows[i].Cells["gridCTPhieuDatHang_cNguyenLieu"].Value;
                chiTiet.SoLuong    = Convert.ToDecimal(grid_chiTietPhieuDat.Rows[i].Cells["gridCTPhieuDatHang_cLuongDat"].Value);

                dto.ChiTietHangNhap.Add(chiTiet);
            }
        }
        private void bt_lapPhieuDatHang_Click(object sender, EventArgs e)
        {
            ThongTinHangNhapDTO ttNhap = new ThongTinHangNhapDTO();

            dongGoiThongTinThongTinHangNhapDTO(ttNhap);
            int kq = ThongTinHangNhapBUS.themThongTinHangNhap(ttNhap);

            if (kq != 0)
            {
                MessageBox.Show("Lập phiếu thành công!", "[!] Thông báo");
                bt_lapPhieuDatHang.Enabled = false;
            }
            else
            {
                MessageBox.Show("Lập phiếu thất bại!", "[!] Thông báo");
                bt_lapPhieuDatHang.Enabled = true;
            }
        }
示例#4
0
 public static int themThongTinHangNhap(ThongTinHangNhapDTO ttNhap)
 {
     return(ThongTinHangNhapDAO.themThongTinHangNhap(ttNhap));
 }
 private void dongGoiThongTinThongTinHangNhapDTO(ThongTinHangNhapDTO dto)
 {
     dto.KhoHang  = KhoHangBUS.layThongTinKhoHangTheoNhaHang(GlobalVariables.maNhaHang);
     dto.NgayNhap = DateTime.Now;
     dongGoiChiTietHangNhapDTO(dto);
 }