Пример #1
0
        public void print()
        {
            using (pdoc = new PrintDocument())
            {
                PrinterSettings ps    = new PrinterSettings();
                Font            font  = new Font("Courier New", 15);
                PaperSize       psize = new PaperSize("Custom", 100, 200);
                pdoc.DefaultPageSettings.PaperSize        = psize;
                pdoc.DefaultPageSettings.PaperSize.Height = 820;
                pdoc.DefaultPageSettings.PaperSize.Width  = 520;

                pdoc.PrinterSettings.PrinterName = PrinterName;
                pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

                LogAdapter.Info("user id : " + WindowsIdentity.GetCurrent().Name, "order", "billing");
                LogAdapter.Info("pdoc.PrinterSettings.PrinterName  : " + pdoc.PrinterSettings.PrinterName, "order", "billing");
                LogAdapter.Info("isvalid : " + pdoc.PrinterSettings.IsValid.ToString(), "order", "billing");

                LogAdapter.Info("user id : " + WindowsIdentity.GetCurrent().Name, "order", "billing");



                Task.Run(() => pdoc.Print());
                //foreach (string printerName in PrinterSettings.InstalledPrinters)
                //{

                //    LogAdapter.Info("Printer lists: " + printerName, "", "");

                //}
            }
        }
Пример #2
0
        public void TotalSummaryPrint(decimal ordertotal, decimal denominatortotal)
        {
            PrintingSystem.TotalSummaryPrint tspt = new PrintingSystem.TotalSummaryPrint();

            tspt.PrinterName = ConfigurationManager.AppSettings["CommonPrinter"].ToString();

            tspt.OrderTotal      = ordertotal;
            tspt.DenominatorTotl = denominatortotal;
            tspt.TodaysDate      = DateTime.Now;
            tspt.Difference      = ordertotal - denominatortotal;
            LogAdapter.Info("Before Summary Print", "CurrencyDenominator", "TotalSummaryPrint");
            Task.Run(() => tspt.print());
            LogAdapter.Info("After Summary print", "CurrencyDenominator", "TotalSummaryPrint");

            LogAdapter.Info("Start Basic Report Print", "CurrencyDenominator", "TotalSummaryPrint");
            DateTime dtFilter = DateTime.Now;

            if (dtFilter.Hour < 4)
            {
                dtFilter = DateTime.Now.AddDays(-1);
            }
            //Todo: need to generate reports

            LogAdapter.Info("End Basic Report Print", "CurrencyDenominator", "TotalSummaryPrint");
        }
Пример #3
0
 public void OpenDrawer()
 {
     try
     {
         if (srPort.IsOpen)
         {
             LogAdapter.Info("Cash drawer port now opening", "CashDrawer", "OpenDrawer");
             srPort.Write("open");
             srPort.Close();
             LogAdapter.Info("Cash drawer now closed", "CashDrawer", "OpenDrawer");
         }
         else
         {
             LogAdapter.Info("Cash drawer port still closed", "CashDrawer", "OpenDrawer");
         }
     }
     catch (Exception ex) {
         LogAdapter.Error(ex.Message, "CashDrawer", "OpenDrawer");
         if (srPort.IsOpen)
         {
             LogAdapter.Info("Cash drawer port open", "CashDrawer", "OpenDrawer Inside Catch");
             srPort.Close();
             LogAdapter.Info("Cash drawer port closed", "CashDrawer", "OpenDrawer Inside Catch");
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Row update handler for providers that require Row Update Handling
        /// </summary>
        /// <param name="row"></param>
        public void OnRowUpdate(DataRow row)
        {
            if (row.RowState == DataRowState.Deleted)
            {
                return;
            }

            if (!hasAutoincrementedColumn)
            {
                return;
            }

            string oidColumnName = this.autoIncrementColumn.Name;
            Type   t             = row[oidColumnName].GetType();

            if (t != typeof(int))
            {
                return;
            }

            // Ist schon eine ID vergeben?
            if (((int)row[oidColumnName]) > 0)
            {
                return;
            }
            bool       unchanged = (row.RowState == DataRowState.Unchanged);
            IDbCommand cmd       = provider.NewSqlCommand(this.conn);

            cmd.CommandText = provider.GetLastInsertedId(this.tableName, this.autoIncrementColumn.Name);
            DumpBatch(cmd.CommandText);

            using (IDataReader reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    object oidValue = reader.GetValue(0);
                    if (this.verboseMode)
                    {
                        if (oidValue == DBNull.Value)
                        {
                            LogAdapter.Info(oidColumnName + " = DbNull");
                        }
                        else
                        {
                            LogAdapter.Info(oidColumnName + " = " + oidValue);
                        }
                    }
                    row[oidColumnName] = oidValue;
                    if (unchanged)
                    {
                        row.AcceptChanges();
                    }
                }
                else
                {
                    throw new NDOException(33, "Can't read autonumbered id from the database.");
                }
            }
        }
Пример #5
0
        public ActionResult Pay(long Id, decimal PaidAmount, string Seats, OrderedProduct[] newItems,
                                OrderedProduct[] oldItems, int Status = 0)
        {
            LogAdapter.Info("Id" + Id.ToString() + "PaidAmount : " + PaidAmount.ToString() + "Seats: " + Seats, "BillConntroller", "Pay");
            LogAdapter.Info("Cash drawer start initialise: orderId" + Id.ToString(), "BillConntroller", "Pay");
            RTCashDrawer cd = new RTCashDrawer();

            LogAdapter.Info("Cash drawer stop initialise: orderId" + Id.ToString(), "BillConntroller", "Pay");
            LogAdapter.Info("Cash drawer start open orderid : " + Id.ToString(), "BillConntroller", "Pay");
            cd.OpenDrawer();
            LogAdapter.Info("Cash drawer stop open orderid : " + Id.ToString(), "BillConntroller", "Pay");
            cd.Dispose();
            LogAdapter.Info("Cash drawer disposed" + Id.ToString(), "BillConntroller", "Pay");
            Order orderToUpdate = null;

            if (Id == 0)
            {
                MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
                orderToUpdate = new Order()
                {
                    CreatedBy = (Guid)user.ProviderUserKey, CreatedDate = DateTime.Now
                };
            }
            else
            {
                orderToUpdate = db.Orders.Where(i => i.Id == Id).Single();
            }
            decimal TotalAmount   = orderToUpdate.OrderedProducts.Where(op => op.Status == 1).Sum(op => (op.Quantity * op.Price)).Value;
            decimal BalanceAmount = PaidAmount - TotalAmount;

            PoleDisplay pole = new PoleDisplay();

            //pole.ClearDisplay();
            pole.DisplayPaid(string.Format("{0,20}", "Paid: " + string.Format(PaidAmount.ToString("0.00"))), string.Format("{0,20}", "Bal: " + string.Format(BalanceAmount.ToString("0.00"))));
            pole.Dispose();


            bool needPrint = false;

            if (orderToUpdate.Status != (byte)StatusType.Bill)
            {
                needPrint = true;
            }

            UpdateBillForOrder(newItems, TotalAmount, PaidAmount, BalanceAmount, ref orderToUpdate);
            long newId = Save(Id, ref orderToUpdate, StatusType.Paid, newItems, Seats, oldItems, ref needPrint, Status);



            if (needPrint)
            {
                PrintBill(newId);
            }
            PushToClient(newId);

            ModelState.Clear();
            return(View("OrderedProducts", new Order()));
        }
Пример #6
0
        public ActionResult SaveMAsterDishes(string data)
        {
            // string j = @"{""data"":[{""masterProdId"":""14"",""sNo"":""1"",""childProdIds"":[""15"",""16""]},{""masterProdId"":""17"",""sNo"":""2"",""childProdIds"":[""18"",""19""]},{""masterProdId"":""14"",""sNo"":""1"",""childProdIds"":[""15"",""16""]}]}";
            ProductContainer pro = new ProductContainer(data);


            foreach (var iter in pro.lstProdMapRow)
            {
                int tempID = Convert.ToInt32(iter.masterProdId);
                var prod   = db.Products.First(i => i.Id == tempID);
                prod.Sno             = Convert.ToInt32(iter.sNo);
                prod.MasterProductID = null;
                for (int incre = 0; incre < iter.childProdIds.Length; incre++)
                {
                    int childId   = Convert.ToInt32(iter.childProdIds.GetValue(incre).ToString());
                    var childProd = db.Products.First(j => j.Id == childId);
                    childProd.Sno             = Convert.ToInt32(incre + 1);
                    childProd.MasterProductID = Convert.ToInt32(iter.masterProdId);
                    db.Entry(childProd).State = EntityState.Modified;
                }
                db.Entry(prod).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException ex) {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();

                    foreach (var failure in ex.EntityValidationErrors)
                    {
                        sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                        foreach (var error in failure.ValidationErrors)
                        {
                            sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                            sb.AppendLine();
                        }
                    }

                    //throw new System.Data.Entity.Validation.DbEntityValidationException(
                    //    "Entity Validation Failed - errors follow:\n" +
                    //    sb.ToString(), ex
                    //); // Add the original exception as the innerException
                    LogAdapter.Info(sb.ToString(), "aa", "bb");
                }
            }

            return(Json(new { message = "Successfully Saved the Dishes Order" }, JsonRequestBehavior.AllowGet));;
        }
Пример #7
0
        public void print()
        {
            using (pdoc = new PrintDocument())
            {
                PrinterSettings ps    = new PrinterSettings();
                Font            font  = new Font("Verdana", 15);
                PaperSize       psize = new PaperSize("Custom", 100, 200);
                pdoc.DefaultPageSettings.PaperSize        = psize;
                pdoc.DefaultPageSettings.PaperSize.Height = 820;
                pdoc.DefaultPageSettings.PaperSize.Width  = 520;

                pdoc.PrinterSettings.PrinterName = PrinterName;
                pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
                LogAdapter.Info("user id : " + WindowsIdentity.GetCurrent().Name, "order", "printing");

                Task.Run(() => pdoc.Print());
            }
        }
        public void SimpleCoverage()
        {
            var innerMessage = "";

            var inner = new TestLogger();
            var adapter = new LogAdapter(inner);
            inner.MethodCalled += (s, e) =>
            {
                innerMessage = e.Message;
            };
            var obj = new object();
            const string format = "{0}";
            var formatProvider = CultureInfo.InvariantCulture;
            var exception = new Exception();

            // we are going to call methods on the adapter and verify that the
            // reciprocal methods are called on the inner logger instance


            // Debug Object
            adapter.Debug(obj);
            Assert.AreEqual("Debug(object message)", innerMessage);



            // Debug Object, Exception
            adapter.Debug(obj, exception);
            Assert.AreEqual("Debug(object message, Exception exception)", innerMessage);





            // Error Object
            adapter.Error(obj);
            Assert.AreEqual("Error(object message)", innerMessage);

            // Error Object, Exception
            adapter.Error(obj, exception);
            Assert.AreEqual("Error(object message, Exception exception)", innerMessage);





            // Fatal Object
            adapter.Fatal(obj);
            Assert.AreEqual("Fatal(object message)", innerMessage);

            // Fatal Object, Exception
            adapter.Fatal(obj, exception);
            Assert.AreEqual("Fatal(object message, Exception exception)", innerMessage);







            // Info Object
            adapter.Info(obj);
            Assert.AreEqual("Info(object message)", innerMessage);

            // Info Object, Exception
            adapter.Info(obj, exception);
            Assert.AreEqual("Info(object message, Exception exception)", innerMessage);



            // Trace Object
            adapter.Trace(obj);
            Assert.AreEqual("Trace(object message)", innerMessage);

            // Trace Object, Exception
            adapter.Trace(obj, exception);
            Assert.AreEqual("Trace(object message, Exception exception)", innerMessage);


            



            // Warn Object
            adapter.Warn(obj);
            Assert.AreEqual("Warn(object message)", innerMessage);

            // Warn Object, Exception
            adapter.Warn(obj, exception);
            Assert.AreEqual("Warn(object message, Exception exception)", innerMessage);



        }
        public void MockedCoverage()
        {

            var inner = MockRepository.GenerateMock<TestLogger>();


            var adapter = new LogAdapter(inner);

            var obj = new object();
            const string format = "{0}";
            var formatProvider = CultureInfo.InvariantCulture;
            var exception = new Exception();

            // we are going to call methods on the adapter and verify that the
            // reciprocal methods are called on the inner logger instance


            // Debug Object
            adapter.Debug(obj);
            inner.AssertWasCalled(i => i.Debug(obj));


            // Debug Object, Exception
            adapter.Debug(obj, exception);
            inner.AssertWasCalled(i => i.Debug(obj, exception));


 
            // Error Object
            adapter.Error(obj);
            inner.AssertWasCalled(i => i.Error(obj));

            // Error Object, Exception
            adapter.Error(obj, exception);
            inner.AssertWasCalled(i => i.Error(obj, exception));

 


            // Fatal Object
            adapter.Fatal(obj);
            inner.AssertWasCalled(i => i.Fatal(obj));

            // Fatal Object, Exception
            adapter.Fatal(obj, exception);
            inner.AssertWasCalled(i => i.Fatal(obj, exception));

 




            // Info Object
            adapter.Info(obj);
            inner.AssertWasCalled(i => i.Info(obj));

            // Info Object, Exception
            adapter.Info(obj, exception);
            inner.AssertWasCalled(i => i.Info(obj, exception));

 


            // Trace Object
            adapter.Trace(obj);
            inner.AssertWasCalled(i => i.Trace(obj));

            // Trace Object, Exception
            adapter.Trace(obj, exception);
            inner.AssertWasCalled(i => i.Trace(obj, exception));

      



            // Warn Object
            adapter.Warn(obj);
            inner.AssertWasCalled(i => i.Warn(obj));

            // Warn Object, Exception
            adapter.Warn(obj, exception);
            inner.AssertWasCalled(i => i.Warn(obj, exception));

 
            
        }