Ejemplo n.º 1
0
        public HttpResponseMessage PrintReceipt(PrintReceiptModel model)
        {
            ResponseStatus response = new ResponseStatus();

            try
            {
                if (ModelState.IsValid)
                {
                    var data = _repository.PrintReceipt(model);
                    if (data.OrderId > 0)
                    {
                        response.serverResponseTime = System.DateTime.Now;
                        response.isSuccess          = true;
                        return(Request.CreateResponse(HttpStatusCode.OK, new { data, response }));
                    }
                    else
                    {
                        response.serverResponseTime = System.DateTime.Now;
                        response.isSuccess          = false;
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, new { response }));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !", ex));
            }
        }
Ejemplo n.º 2
0
        public DataSet PrintReceipt(PrintReceiptModel model)
        {
            if (model.IsReprinted)
            {
                printLogRepository.Create(model);
            }

            var serverDataSet = new DataSet();

            serverDataSet.EnforceConstraints = false;
            serverDataSet.Tables.Add(new DataTable(nameof(dbContext.SaleTransactions)));
            serverDataSet.Tables.Add(new DataTable(nameof(dbContext.PurchaseTransactions)));

            using (var sqlConn = new SqlConnection(dbContext.Database.GetDbConnection().ConnectionString))
            {
                var query = string.Empty;
                var sa    = new SqlDataAdapter();

                query = dbContext.SaleTransactions
                        .Where(a => a.SaleId == model.TransactionId).ToQueryString();
                sa = new SqlDataAdapter(query.ToString(), sqlConn);
                sa.Fill(serverDataSet, nameof(dbContext.SaleTransactions));
                sa.Dispose();

                query = $"SELECT {model.TransactionId} AS PurchaseId";
                sa    = new SqlDataAdapter(query.ToString(), sqlConn);
                sa.Fill(serverDataSet, nameof(dbContext.PurchaseTransactions));
                sa.Dispose();

                query = null;
            }

            return(serverDataSet);
        }
        public PrintLog Create(PrintReceiptModel model)
        {
            var transaction = dbContext.Database.BeginTransaction();

            try
            {
                var table   = model.TransactionTypeCode == "I" ? "PurchaseTransactions" : "SaleTransactions";
                var colName = model.TransactionTypeCode == "I" ? "PurchaseId" : "SaleId";
                var qry     = $"UPDATE {table} SET {nameof(PurchaseTransaction.PrintCount)} = " +
                              $"{nameof(PurchaseTransaction.PrintCount)}+1 WHERE {colName} ={model.TransactionId}";
                dbContext.Database.ExecuteSqlRaw(qry);

                var printLog = new PrintLog()
                {
                    DTPrinted           = DateTime.Now,
                    TransactionId       = model.TransactionId,
                    TransactionTypeCode = model.TransactionTypeCode,
                    PrintReasons        = model.ReprintRemarks,
                    ReceiptNum          = model.ReceiptNum,
                    UserAccountId       = model.UserAccoountId,
                    UserAccountName     = model.UserFullName
                };
                dbContext.PrintLogs.Add(printLog);
                dbContext.SaveChanges();

                transaction.Commit();
                return(printLog);
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
        }
Ejemplo n.º 4
0
 public IActionResult PrintReceipt([FromRoute] long id, [FromBody] PrintReceiptModel model)
 {
     try
     {
         var result = repository.PrintReceipt(model);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
Ejemplo n.º 5
0
 DataSet ITransDbRepository <Inyard> .PrintReceipt(PrintReceiptModel model) => throw new NotImplementedException();
Ejemplo n.º 6
0
        public void PrintReceipt(PrintReceiptModel model)

        {
            throw new NotImplementedException();
        }