public IHttpActionResult Put([FromBody] CTPhieuXuat x) { if (!ModelState.IsValid) { return(BadRequest("Not a valid data")); } CTPhieuXuatDAO.Instance.Update(x.MaCTPX, x.MaPX, x.MaHH, x.SoLuong, x.GiaXuat); return(Ok()); }
public IHttpActionResult Post([FromBody] CTPhieuXuat x) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } CTPhieuXuatDAO.Instance.Create(x.MaCTPX, x.MaPX, x.MaHH, x.SoLuong, x.GiaXuat);//string MaCTPX, string MaPX, string MaHH, string SoLuong, string GiaXuat return(Ok()); }
public List <CTPhieuXuat> GetList() { List <CTPhieuXuat> list = new List <CTPhieuXuat>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT * FROM dbo.CTPHIEUXUAT"); foreach (DataRow item in data.Rows) { CTPhieuXuat obj = new CTPhieuXuat(item); list.Add(obj); } return(list); }
public static List <CTPhieuXuat> ChuyenDoiDTOCTPhieuXuat(DataTable bang) { List <CTPhieuXuat> kq = new List <CTPhieuXuat>(); foreach (DataRow dong in bang.Rows) { CTPhieuXuat a = new CTPhieuXuat(); a.MaChiTietXuat = dong["MaChiTietXuat"].ToString(); a.MaPhieuXuat = dong["MaPhieuXuat"].ToString(); a.MaSP = dong["MaSP"].ToString(); a.DonGiaSP = float.Parse(dong["DonGiaSP"].ToString()); a.ThanhTien = float.Parse(dong["ThanhTien"].ToString()); a.Thue = float.Parse(dong["Thue"].ToString()); a.SoLuongMua = int.Parse(dong["SoLuongMua"].ToString()); kq.Add(a); } return(kq); }
public bool DeleteCTPhieuXuat(CTPhieuXuat px) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseAddress); //HTTP POST var postTask = client.DeleteAsync("ctphieuxuat?MaCTPX=" + px.MaCTPX); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { ListCTPhieuXuat = GetListCTPhieuXuat(); return(true); } else { return(false); } } }
public bool PutCTPhieuXuat(CTPhieuXuat px) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseAddress); //HTTP POST var postTask = client.PutAsJsonAsync <CTPhieuXuat>("ctphieuxuat", px); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { ListCTPhieuXuat = GetListCTPhieuXuat(); return(true); } else { return(false); } } }
// Xóa chi tiết phiếu xuất public void XoaCTPX(CTPhieuXuat ctpx) { dah.ThucThiCauLenhSQL("DELETE FROM tblCTPX where MaPX ='" + ctpx.Mapx + "'"); }
// Sửa chi tiết phiếu xuất public void SuaCTPX(CTPhieuXuat ctpx) { dah.ThucThiCauLenhSQL("UPDATE tblCTPX SET SoLuongXuat ='" + ctpx.Soluongxuat + "', DonGiaXuat ='" + ctpx.Dongiaxuat + "', ThanhTien =(" + ctpx.Soluongxuat + " * " + ctpx.Dongiaxuat + "), DonViTinh ='" + ctpx.Donvitinh + "' where MaPX ='" + ctpx.Mapx + "'"); }
// Thêm chi tiết phiếu xuất public void ThemCTPX(CTPhieuXuat ctpx) { dah.ThucThiCauLenhSQL("INSERT INTO tblCTPX VALUES('" + ctpx.Mapx + "','" + ctpx.Masp + "','" + ctpx.Soluongxuat + "','" + ctpx.Dongiaxuat + "',(" + ctpx.Soluongxuat + " * " + ctpx.Dongiaxuat + "),'" + ctpx.Donvitinh + "')"); }
private void buttonThem_Click(object sender, EventArgs e) { //load du lieu loadPhieuXuat(XL_PhieuXuat.LayDuLieuPhieuXuat()); //co hieu int cohieu = 1; //phieu nhap string maphieuxuat = textBoxMaPhieuXuat.Text; string ngayxuat = dateTimePickerNgayXuat.Value.ToString(); string manhanvien = gridLookUpEditNhanVien.Text; string khachang = gridLookUpEditMaKhachHang.Text; string dieukhoan = gridLookUpEditDieuKhoanThanhToan.Text; string hinhthucthanhtoan = gridLookUpEditHinhThucThanhToan.Text; string hanthanhtoan = dateTimePickerHanThanhToan.Value.ToString(); string tientratruoc = textBoxTienTraTruoc.Text; string ngaygiao = dateTimePickerNgayGiao.Value.ToString(); //tien double TongTien = 0; int soluong; float gia; for (int i = 0; i < dataGridViewCTPhieuXuat.Rows.Count; i++) { //object m = dataGridViewCTPhieuXuat["SoLuong", i].Value; //object n = dataGridViewCTPhieuXuat["GiaLucNhap", i].Value; object n = dataGridViewCTPhieuXuat.Rows[i].Cells["GiaLucNhap"].Value; object m = dataGridViewCTPhieuXuat.Rows[i].Cells["SoLuong"].Value; if (m != null && n != null) { soluong = int.Parse(m.ToString()); gia = float.Parse(n.ToString()); double thue = (soluong * gia) * 0.1; TongTien += ((soluong * gia) + thue); } } textBoxTongTien.Text = TongTien.ToString(); //xet ma px for (int i = 0; i < px.Count; i++) { if (maphieuxuat == px[i].MaPhieuXuat) { cohieu = 0; break; } } //phieunhap if (maphieuxuat != "" && cohieu == 1 && ngayxuat != "" && hanthanhtoan != "" && manhanvien != "" && ngaygiao != "" && TongTien != 0 && khachang != "" && dieukhoan != "" && hinhthucthanhtoan != "" && tientratruoc != "" && dataGridViewCTPhieuXuat.Rows.Count - 1 != 0) { bool ThemPhieuXuat = XL_PhieuXuat.ThemPhieuXuat(maphieuxuat, ngayxuat, manhanvien, khachang, hinhthucthanhtoan, dieukhoan, TongTien, hanthanhtoan, tientratruoc, ngaygiao); if (ThemPhieuXuat == true) { List <bool> ThemCTPhieuXuat = new List <bool>(); int lengt = dataGridViewCTPhieuXuat.Rows.Count; //ct phieu nhap int sl = ctpx.Count; for (int i = 0; i < lengt; i++) { // object m = dataGridViewCTPhieuXuat.Rows[i].Cells["MaSP"].Value; object n = dataGridViewCTPhieuXuat.Rows[i].Cells["GiaLucNhap"].Value; object o = dataGridViewCTPhieuXuat.Rows[i].Cells["SoLuong"].Value; object makho = dataGridViewCTPhieuXuat.Rows[i].Cells["MaKho"].Value; if (m != null && n != null && o != null) { CTPhieuXuat temp = new CTPhieuXuat(); //cap phat ma ct phieu xuat tu dong sl += 1; temp.MaChiTietXuat = string.Format("CTPX" + sl.ToString()); temp.MaPhieuXuat = maphieuxuat; temp.MaSP = m.ToString(); temp.MaKho = makho.ToString(); temp.DonGiaSP = float.Parse(n.ToString()); temp.SoLuongMua = int.Parse(o.ToString()); float thue = 0.1f; temp.Thue = thue; //tien moi loai sp float soluongsp = int.Parse(o.ToString()); float giasp = float.Parse(n.ToString()); double tienthue = (soluongsp * giasp * 0.1); double tien = ((soluongsp * giasp) + tienthue); temp.ThanhTien = float.Parse(tien.ToString()); bool Them = XL_CTPhieuXuat.ThemCTPhieuXuat(temp.MaChiTietXuat, temp.MaPhieuXuat, temp.MaSP, temp.MaKho, temp.DonGiaSP, temp.ThanhTien, temp.Thue, temp.SoLuongMua); bool Sua = XL_SanPham.CapNhatSanPham(temp.MaKho, temp.MaSP, temp.SoLuongMua); // ThemCTPhieuNhap.Add(Them); } } //bien dem xem co luu dc tat ca k int dem = 0; for (int i = 0; i < ThemCTPhieuXuat.Count; i++) { if (ThemCTPhieuXuat[i] == true) { dem++; } } if (dem == ThemCTPhieuXuat.Count) { MessageBox.Show("Thêm thành công!"); this.Close(); } else { MessageBox.Show("Thêm thất bại!"); this.Close(); } } } }
// Xóa chi tiết phiếu xuất public void XoaCTPX(CTPhieuXuat ctpx) { dal.XoaCTPX(ctpx); }
// Sửa chi tiết phiếu xuất public void SuaCTPX(CTPhieuXuat ctpx) { dal.SuaCTPX(ctpx); }
// Thêm chi tiết phiếu xuất public void ThemCTPX(CTPhieuXuat ctpx) { dal.ThemCTPX(ctpx); }