public bool ThemMoiBaoHanh(BaoHanh baoHanh) { try { OpenDataBase(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "ThemMoiBaoHanh"; sqlCommand.Connection = sqlConnection; sqlCommand.Parameters.Add("@MaBaoHanh", SqlDbType.Char).Value = baoHanh.MaBaoHanh; sqlCommand.Parameters.Add("@MaMay", SqlDbType.Char).Value = baoHanh.MaMay; //sqlCommand.Parameters.Add("@MaHoaDon", SqlDbType.Char).Value = baoHanh.MaHoaDon; sqlCommand.Parameters.Add("@MaPhieuXuat", SqlDbType.Char).Value = baoHanh.MaPhieuXuat; //sqlCommand.Parameters.Add("@MaKhachHang", SqlDbType.Char).Value = baoHanh.MaKhachHang; sqlCommand.Parameters.Add("@NgayBatDau", SqlDbType.DateTime).Value = baoHanh.NgayBatDau; sqlCommand.Parameters.Add("@NgayHetHan", SqlDbType.DateTime).Value = baoHanh.NgayHetHan; int k = sqlCommand.ExecuteNonQuery(); return(k > 0); } catch (Exception ex) { throw ex; } }
private BaoHanh LayThongTinBaoHanh() { int id = 0; BaoHanh p = new BaoHanh(id, int.Parse(comboBoxTenHang.ValueMember), textBoxSoEmei.Text, int.Parse(comboBoxTenKhachHang.ValueMember), dateTimePickerNgayMuaBH.Value, textBoxThoiGianBaoHanh.Text); return(p); }
public List <BaoHanh> HienThiDanhSachBaoHanh() { try { OpenDataBase(); SqlCommand sqlCommand = new SqlCommand(); List <BaoHanh> DanhSachBaoHanh = new List <BaoHanh>(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "HienThiDanhSachBaoHanh"; sqlCommand.Connection = sqlConnection; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { BaoHanh baoHanh = new BaoHanh() { MaBaoHanh = sqlDataReader.GetString(0), TenSanPham = sqlDataReader.GetString(1), MaMay = sqlDataReader.GetString(2), MaHoaDon = sqlDataReader.GetString(3), MaPhieuXuat = sqlDataReader.GetString(4), MaKhachHang = sqlDataReader.GetString(5), NgayBatDau = sqlDataReader.GetDateTime(6), NgayHetHan = sqlDataReader.GetDateTime(7) }; DanhSachBaoHanh.Add(baoHanh); } CloseDataBase(); sqlDataReader.Close(); return(DanhSachBaoHanh); } catch (Exception ex) { throw ex; } }
public ActionResult DeleteConfirmed(string id) { BaoHanh baoHanh = db.BaoHanh.Find(id); db.BaoHanh.Remove(baoHanh); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaBaoHanh,ChiTietBH")] BaoHanh baoHanh) { if (ModelState.IsValid) { db.Entry(baoHanh).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(baoHanh)); }
public async Task <ActionResult <BaoHanhDTO> > Add(BaoHanh bh) { try { return(await repo.AddBH(bh)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <dynamic> chiTietSanPhamSeri(string maSeri) { SanPhamSeriWarranty sp = null; using (var connection = new SqlConnection(connectionstr)) { DetailSanPhamSeri detailSeri = new DetailSanPhamSeri(); string query = @"SELECT SANPHAM.MaSeri , SANPHAM.MaSP, (SELECT CHITIETDONDATHANG.MaDDH FROM CHITIETDONDATHANG INNER JOIN DONDATHANG ON DONDATHANG.MaDDH = CHITIETDONDATHANG.MaDDH WHERE CHITIETDONDATHANG.MaSeri = SANPHAM.MaSeri AND TrangThai=1) AS MaDDH , (SELECT CHITIETPHIEUNHAP.MaPN FROM CHITIETPHIEUNHAP WHERE CHITIETPHIEUNHAP.MaSeri = SANPHAM.MaSeri) AS MaPN FROM SANPHAM WHERE MaSeri='" + maSeri + "' AND TrangThai=0"; sp = await connection.QueryFirstOrDefaultAsync <SanPhamSeriWarranty>(query, commandType : CommandType.Text); if (sp == null) { return("This seri is uncorrect! Please check again!"); } detailSeri.sp = sp; ChiTietDonDatHangVM ctDDH = await this.chiTietDonDatHangAD(sp.MaDDH); detailSeri.ddh = ctDDH; ChiTietPhieuNhapVM ctPN = await this.chiTietPhieuNhapAD(sp.MaPN); detailSeri.pn = ctPN; IEnumerable <BaoHanh> dsbh = null; string query2 = @"SELECT * FROM BAOHANH BH WHERE TrangThai !=-1 AND MaSeri='" + maSeri + "' ORDER BY NgayTao "; dsbh = await connection.QueryAsync <BaoHanh>(query2, commandType : CommandType.Text); if (dsbh != null) { foreach (var item in dsbh) { BaoHanh bh = new BaoHanh(); bh.MaBH = item.MaBH; bh.MaNV = item.MaNV; bh.MaSeri = item.MaSeri; bh.NgayTao = item.NgayTao; bh.TrangThai = item.TrangThai; bh.NoiDung = item.NoiDung; detailSeri.dsBH.Add(bh); } } return(detailSeri); } }
public ActionResult Create([Bind(Include = "MaBaoHanh,ChiTietBH")] BaoHanh baoHanh) { if (ModelState.IsValid) { db.BaoHanhs.Add(baoHanh); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(baoHanh)); }
public async Task <dynamic> layChiTietBaoHanh(int maBH) { BaoHanh baoHanh = null; using (var connection = new SqlConnection(connectionstr)) { var p = new DynamicParameters(); p.Add("@ID", maBH); p.Add("@TABLE", "BAOHANH"); baoHanh = connection.QuerySingleOrDefault <BaoHanh>("SP_GETDETAILBYID", p, commandType: CommandType.StoredProcedure); } return(baoHanh); }
// GET: BaoHanhs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BaoHanh baoHanh = db.BaoHanh.Find(id); if (baoHanh == null) { return(HttpNotFound()); } return(View(baoHanh)); }
public bool insertPhieubaohanh(BaoHanh bh) { string strInsert = "insert into PhieuBaoHanh values( "; strInsert += "'" + bh.MaPhieuBH + "',"; strInsert += "'" + bh.MaKhachHang + "',"; strInsert += "'" + bh.MaHang + "',"; strInsert += "'" + bh.SoKhung + "',"; strInsert += "'" + bh.SoMay + "',"; strInsert += "'" + bh.NgayMua + "',"; strInsert += "'" + bh.ThoiGianBH + "')"; if (!data.UpdateData(strInsert)) { Error = data.Error; return(false); } return(true); }
public async Task <dynamic> themBaoHanh(BaoHanh baoHanh) { using (var connection = new SqlConnection(connectionstr)) { var p = new DynamicParameters(); p.Add("@NoiDung", baoHanh.NoiDung); p.Add("@MaSeri", baoHanh.MaSeri); p.Add("@NgayTao", baoHanh.NgayTao); p.Add("Result", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); connection.Query("BAOHANH_INSERT", p, commandType: CommandType.StoredProcedure); int result = p.Get <int>("Result"); if (result == 0) { return("Seri is not exist!"); } return("success"); } }
public ActionResult Edit([Bind(Include = "MaBH,HinhThucBH,MoTaBH")] BaoHanh baoHanh) { if (ModelState.IsValid) { if (Common.MaNV != "") { } else { Common.Alert = "Đăng nhập trước khi chỉnh sữa !"; return(RedirectToAction("Index", "Logins")); } db.Entry(baoHanh).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(baoHanh)); }
public bool updatePhieubaohanh(BaoHanh nv, string ma) { string strUpdate = "update PhieuBaoHanh set "; strUpdate += "MAPHIEUBH='" + nv.MaPhieuBH + "',"; strUpdate += "MAKHACHHANG='" + nv.MaKhachHang + "',"; strUpdate += "MAHANG='" + nv.MaHang + "',"; strUpdate += "SOKHUNG='" + nv.SoKhung + "',"; strUpdate += "SOMAY='" + nv.SoMay + "',"; strUpdate += "NGAYMUA='" + nv.NgayMua + "',"; strUpdate += "THOIGIANBH='" + nv.ThoiGianBH + "' "; strUpdate += "where MAPHIEUBH='" + ma + "'"; if (!data.UpdateData(strUpdate)) { Error = data.Error; return(false); } return(true); }
public async Task <dynamic> capNhatBaoHanh(BaoHanh baoHanh) { BaoHanh baoHanhcopy; using (var connection = new SqlConnection(connectionstr)) { var p = new DynamicParameters(); p.Add("@ID", baoHanh.MaBH); p.Add("TABLE", "BAOHANH"); baoHanhcopy = connection.QuerySingleOrDefault <BaoHanh>("SP_GETDETAILBYID", p, commandType: CommandType.StoredProcedure); } if (baoHanhcopy == null) { var response = await tbl.TBLoi(ThongBaoLoi.Loi500, "Account is not exist!"); return(response.Content); } try { using (var connection = new SqlConnection(connectionstr)) { var p = new DynamicParameters(); p.Add("@MaBH", baoHanh.MaBH); p.Add("@MaNV", baoHanh.MaNV); p.Add("@MaSeri", baoHanh.MaSeri); p.Add("@TrangThai", baoHanh.TrangThai); p.Add("@NoiDung", baoHanh.NoiDung); p.Add("@NgayTao", baoHanh.NgayTao); connection.Execute("BAOHANH_UPDATE", p, commandType: CommandType.StoredProcedure); return(baoHanh); } } catch (Exception ex) { var response = await tbl.TBLoi(ThongBaoLoi.Loi500, "UnSuitable Value!"); return(response); } }
public bool ThayDoiThongTinBaoHanhDAL(BaoHanh baoHanh) { try { OpenDataBase(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "ChinhSuaThongTinBaoHanh"; sqlCommand.Connection = sqlConnection; sqlCommand.Parameters.Add("@MaBaoHanh", SqlDbType.Char).Value = baoHanh.MaBaoHanh; sqlCommand.Parameters.Add("@MaMay", SqlDbType.Char).Value = baoHanh.MaMay; sqlCommand.Parameters.Add("@MaPhieuXuat", SqlDbType.Char).Value = baoHanh.MaPhieuXuat; sqlCommand.Parameters.Add("@NgayBatDau", SqlDbType.DateTime).Value = baoHanh.NgayBatDau; sqlCommand.Parameters.Add("@NgayHetHan", SqlDbType.DateTime).Value = baoHanh.NgayHetHan; int k = sqlCommand.ExecuteNonQuery(); CloseDataBase(); return(k > 0); } catch (Exception ex) { throw ex; } }
public ActionResult Create([Bind(Include = "MaBH,HinhThucBH,MoTaBH")] BaoHanh baoHanh) { var sl = from p in db.BaoHanh select p; int i = sl.Count() + 1; if (ModelState.IsValid) { if (Common.MaNV != "") { baoHanh.MaBH = "BH" + i.ToString(); } else { Common.Alert = "Đăng nhập trước khi chỉnh sữa !"; return(RedirectToAction("Index", "Logins")); } db.BaoHanh.Add(baoHanh); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(baoHanh)); }
public async Task <IActionResult> capnhat(BaoHanh baoHanh) { dynamic result = await _thongKeBanHangRepository.capNhatBaoHanh(baoHanh); return(Ok(result)); }
private void btLuu_Click(object sender, EventArgs e) { BaoHanh pbh = new BaoHanh(); DateTime Ngay = Convert.ToDateTime(cmbNgaymua.Text); String NgayDeLuu = Ngay.ToString("MM/dd/yyyy"); string result = DateTime.ParseExact(NgayDeLuu, "mm/dd/yyyy", null).AddDays(Convert.ToInt32(cmb_thoigianbh.SelectedValue.ToString())).ToString("mm/dd/yyyy"); // blo.insertPhieubaohanh(pbh); if (txt_sokhung.Text == "") { MessageBox.Show("Không được bỏ trống số khung", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txt_somay.Text == "") { MessageBox.Show("Không được bỏ trống số máy", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { bool kt1 = true; bool kt2 = true; bool kt3 = true; pbh.MaPhieuBH = txt_phieubh.Text; pbh.MaKhachHang = cmb_makh.SelectedValue.ToString(); pbh.MaHang = cmb_maxe.SelectedValue.ToString(); pbh.SoKhung = txt_sokhung.Text; pbh.SoMay = txt_somay.Text; pbh.NgayMua = cmbNgaymua.Text; pbh.ThoiGianBH = result; if (kt1 == false) { MessageBox.Show("Số điện thoại không đúng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (kt2 == false) { MessageBox.Show("Năm sinh không hợp lệ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (kt3 == false) { MessageBox.Show("Giá trị nhập vào lương không hợp lệ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (kt == true) { if (!blo.insertPhieubaohanh(pbh)) { MessageBox.Show("Lỗi hệ thống, Không lưu được", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm bảo hành thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); UC_BaoHanh_Load(sender, e); } } else { if (!blo.updatePhieubaohanh(pbh, txt_phieubh.Text)) { MessageBox.Show(blo.Error, "Thông Báo Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Sửa bảo hành thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); UC_BaoHanh_Load(sender, e); } } } }
public bool ThayDoiThongTinBaoHanhDAL(BaoHanh baoHanh) { return(hienThiBaoHanhDAL.ThayDoiThongTinBaoHanhDAL(baoHanh)); }
public bool ThemBaoHanh(BaoHanh baoHanh) { return(hienThiBaoHanhDAL.ThemMoiBaoHanh(baoHanh)); }