public bool suaPhieuNhap(DTO_PhieuNhap tv) { try { // Ket noi connect.Open(); // Query string string SQL = string.Format("UPDATE PHIEUNHAP " + "SET MANCC= '{1}', NGNHAP='{2}',TONGSL= {3} , TONGTIEN={4} ,GHICHU= N'{5}' " + "WHERE MAPN='{0}'", tv.MAPN, tv.MANCC, tv.NGNHAP, tv.TONGSL, tv.TONGTIEN, tv.GHICHU); // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều). SqlCommand cmd = new SqlCommand(SQL, connect); // Query và kiểm tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { // Dong ket noi connect.Close(); } return(false); }
public DTO_PhieuNhap[] timkiem_PhieuNhap(string mapn) { int i = 0; DataTable infotable = pn.timKiemTheoMaPhieuNhap(mapn); if (infotable.Rows.Count == 0) { DTO_PhieuNhap[] temp = new DTO_PhieuNhap[1]; temp[0] = new DTO_PhieuNhap(getThongTinPN(0, 0), getThongTinPN(1, 0), getThongTinPN(2, 0), getThongTinPN(3, 0), getThongTinPN(4, 0), getThongTinPN(5, 0)); return(temp); } DTO_PhieuNhap[] dtopn = new DTO_PhieuNhap[infotable.Rows.Count]; DataRowCollection result = infotable.Rows; foreach (DataRow row in result) { string[] str = new string[8]; for (int j = 0; j <= 5; j++) { str[j] = row[j].ToString(); } dtopn[i] = new DTO_PhieuNhap(str[0], str[1], str[2], str[3], str[4], str[5]); i++; } return(dtopn); }
public bool themPhieuNhap(DTO_PhieuNhap tv)// THẮNG { try { // Ket noi connect.Open(); string SQL = string.Format("INSERT INTO PHIEUNHAP (MAPN, MANCC, NGNHAP, TONGSL,TONGTIEN, GHICHU) " + "VALUES ('{0}', '{1}', '{2}', {3} , {4}, N'{5}')", tv.MAPN, tv.MANCC, tv.NGNHAP, tv.TONGSL, tv.TONGTIEN, tv.GHICHU); // DỮ LIỆU NHẬP VÀO // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều). SqlCommand cmd = new SqlCommand(SQL, connect); // Query và kiểm tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { // Dong ket noi connect.Close(); } return(false); }
static public string check_Nhap(DTO_PhieuNhap pn) { string error = ""; Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS(); DTO_PhieuNhap[] phieunhap = bus.timkiem_PhieuNhap(pn.MAPN); if (phieunhap[0].MAPN == pn.MAPN) { error += "Phiếu nhập này đã tồn tại"; } return(error); }
private void getDataFromEditUI(DTO_PhieuNhap obj) { txtMaPhieuNhap.Text = obj.MaPhieuNhap; dpNgayLap.SelectedDate = obj.NgayNhap; dpNgayChinhSua.SelectedDate = obj.NgayChinhSua; cbbNhaCungCap.Text = obj.TenNhaCungCap; txtTenNhanVien.Text = obj.TenNhanVien; txtGhiChu.Text = obj.GhiChu; txtTongTien.Text = obj.TongTien.ToString(); isNew = false; }
private void pictureBox3_Click(object sender, EventArgs e) { Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS(); if (dataGridView1.Rows.Count == 0) { PushNoti noti1 = new PushNoti("Error", "Chưa có chi tiết phiếu nhập!"); noti1.Width = this.Width; this.Controls.Add(noti1); noti1.Show(); noti1.ShowNoti(); } DTO_PhieuNhap PN = new DTO_PhieuNhap(txtMaPN.Text, txtMaNCC.Text, DateChange.ToString(dateNgNhap.DateTime), "0", "0", richTextBox1.Text); string error = CheckThongTin.check_Nhap(PN); if (error != "") { PushNoti noti1 = new PushNoti("Error", error); noti1.Width = this.Width; this.Controls.Add(noti1); noti1.Show(); noti1.ShowNoti(); return; } if (bus.themData(PN) == false) { PushNoti noti1 = new PushNoti("Error", "Thêm phiếu nhập không thành công!"); noti1.Width = this.Width; this.Controls.Add(noti1); noti1.Show(); noti1.ShowNoti(); return; } int SL = 0; int GT = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { DTO_CTPhieuNhap ctpn = new DTO_CTPhieuNhap(PN.MAPN, row.Cells[0].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString()); SL += int.Parse(row.Cells[2].Value.ToString()); GT += int.Parse(row.Cells[3].Value.ToString()); DTO_SanPham[] sp = bus.search_SANPHAM(row.Cells[0].Value.ToString()); sp[0].SLUONG = (int.Parse(sp[0].SLUONG) + int.Parse(row.Cells[2].Value.ToString())).ToString(); bus.suaData(sp[0]); bus.themData(ctpn); } PN.TONGSL = SL.ToString(); PN.TONGTIEN = GT.ToString(); bus.suaData(PN); DialogResult = DialogResult.OK; Close(); }
private void checkGroupCTPN(bool isNew, DTO_PhieuNhap phieunhap) { if (isNew) { groupCTPN.IsEnabled = false; } else { groupCTPN.IsEnabled = true; generateChiTietPhieuNhapID(); loadCombobox(); dgvChiTietPhieuNhap.ItemsSource = BUS_ChiTietPhieuNhap.showDataByPhieuNhap(phieunhap.MaPhieuNhap); } }
public UI_ThemPhieuNhap(Grid gridMain, DTO_PhieuNhap obj) { InitializeComponent(); DataContext = new TextFieldsViewModel(); this.gridMain = gridMain; if (obj == null) { generatePhieuNhapID(); checkGroupCTPN(isNew = true, item); } else { getDataFromEditUI(obj); checkGroupCTPN(isNew = false, obj); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Bạn có muốn xóa dòng này?", "Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { if (dgvStockImport.SelectedItem != null) { DTO_PhieuNhap obj = new DTO_PhieuNhap(); obj = dgvStockImport.SelectedItem as DTO_PhieuNhap; String id = obj.MaPhieuNhap; BUS_PhieuNhap.Delete(id); dgvStockImport.ItemsSource = BUS_PhieuNhap.showData(); } } }
public void insert(DTO_PhieuNhap obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { var resultMaNhanVien = db.Database .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'") .FirstOrDefault(); var resultMaNhaCungCap = db.Database .SqlQuery <String>("select MaNhaCungCap from dbo.NhaCungCap where TenNhaCungCap = N'" + obj.TenNhaCungCap + "'") .FirstOrDefault(); PhieuNhap phieuNhap = new PhieuNhap(); phieuNhap.MaPhieuNhap = obj.MaPhieuNhap; phieuNhap.MaNhaCungCap = resultMaNhaCungCap; phieuNhap.MaNhanVien = resultMaNhanVien; phieuNhap.NgayChinhSua = obj.NgayChinhSua; phieuNhap.NgayNhap = obj.NgayNhap; phieuNhap.TongTien = obj.TongTien; phieuNhap.GhiChu = obj.GhiChu; db.PhieuNhaps.Add(phieuNhap); db.SaveChanges(); } }
public bool suaData(DTO_PhieuNhap tv) { return(pn.suaPhieuNhap(tv)); }
public bool themData(DTO_PhieuNhap tv) { return(pn.themPhieuNhap(tv)); }
public void Update(DTO_PhieuNhap obj) { PhieuNhap.Instance.update(obj); }
public void Insert(DTO_PhieuNhap obj) { PhieuNhap.Instance.insert(obj); }