public HttpResponseMessage GetDetail(string receiptId) { try { ReceiptDetailDT rctDetailDT = new ReceiptDetailDT(); DataTable dtReceipt = receiptDT.GetByCond("ID=" + receiptId); DataTable dtDetail = new DataTable(); if (dtReceipt != null) { if (dtReceipt.Rows[0]["Type"].ToString() == "1") { dtDetail = rctDetailDT.GetSellInvoiceReceipt(receiptId); } else if (dtReceipt.Rows[0]["Type"].ToString() == "2") { dtDetail = rctDetailDT.GetSuppReturnReceipt(receiptId); } } return(Request.CreateResponse <string>(HttpStatusCode.OK, JsonConvert.SerializeObject(dtDetail))); } catch (Exception e) { ExceptionHandler.Log(e); return(Request.CreateResponse <string>(HttpStatusCode.OK, "Lỗi: Không đọc được chi tiết phiếu thu."));; } }
public static string GetReceiptCode() { FinReceiptDT receiptDT = new FinReceiptDT(); string mmyy = getMMyy(); DataTable invoiceTable = receiptDT.GetByCond("Code like 'PT" + mmyy + "%'", " Code DESC"); string prefix = "PT" + mmyy; string suffix = "0001"; if (invoiceTable != null && invoiceTable.Rows.Count > 0) { suffix = getSuffix(invoiceTable.Rows[0]["Code"].ToString()); } return(prefix + suffix); }
public FinReceiptRule IsExits(string cond, string message) { try { DataTable dt = dta.GetByCond(cond); if (dt != null && dt.Rows.Count > 0) { IsPassed = false; ErrMessage += message; } return(this); } catch (Exception e) { IsPassed = false; 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(); } }