public static void ReceiveProduct(SelReceiveproductContract receiveProductDTO, SelReceiveproductDetailContract receiveProductDetailDTO, SqlTransaction tran) { try { SelInvoiceDT invoiceDT = new SelInvoiceDT(); DataTable dtInvoice = invoiceDT.GetByID(receiveProductDTO.Invoiceid.ToString()); if (dtInvoice != null && dtInvoice.Rows.Count > 0) { string invoiceCode = dtInvoice.Rows[0]["Code"].ToString(); returnStore(invoiceCode, (int)receiveProductDTO.Storeid, (int)receiveProductDetailDTO.Productid, receiveProductDetailDTO.Quantity, tran); } } catch (Exception e) { throw e; } }
public HttpResponseMessage Delete(string id) { SqlTransaction tran = DataProvider.beginTrans(); try { string message = id; FinReceiptDT receiptDT = new FinReceiptDT(); DataTable dtReceipt = receiptDT.GetByCond("InvoiceId=" + id); if (dtReceipt.Rows.Count > 0) { message = "Lỗi: Phiếu bán hàng đã thu tiền, không thể xóa."; } else { DataTable dtInvoice = invoiceDT.GetByID(id); DataTable invoiceDetail = invoiceDetailDT.GetByCond("InvoiceId=" + id); foreach (DataRow row in invoiceDetail.Rows) { string invCode = dtInvoice.Rows[0]["Code"].ToString(); int storeId = Converter.ToInt32(dtInvoice.Rows[0]["StoreId"]); int productId = Converter.ToInt32(row["ProductId"]); string quantity = row["ProductId"].ToString(); StoreModel.ChangeInvoice(invCode, storeId, productId, quantity, tran); invoiceDetailDT.DeleteViaCond("InvoiceId=" + id, tran); invoiceDT.Delete(id, tran); tran.Commit(); } } return(Request.CreateResponse <string>(HttpStatusCode.OK, message)); } catch (Exception e) { ExceptionHandler.Log(e); tran.Rollback(); return(Request.CreateResponse <string>(HttpStatusCode.OK, "")); } finally { tran.Dispose(); } }
public HttpResponseMessage GetByID(string id) { try { return(Request.CreateResponse <string>(HttpStatusCode.OK, JsonConvert.SerializeObject(dta.GetByID(id)))); } catch (Exception e) { ExceptionHandler.Log(e); return(null); } }