public void ResultErrorTry_Ok()
        {
            int initialValue = Numbers.Number;
            var resultError  = ResultErrorTry(() => SyncFunctions.Division(initialValue), Exceptions.ExceptionError());

            Assert.True(resultError.OkStatus);
        }
        public void ResultErrorTry_Exception()
        {
            const int initialValue = 0;
            var       resultError  = ResultErrorTry(() => SyncFunctions.Division(initialValue), Exceptions.ExceptionError());

            Assert.True(resultError.HasErrors);
            Assert.Equal(ErrorResultType.DivideByZero, resultError.Errors.First().ErrorResultType);
        }
예제 #3
0
 static void Main(string[] args)
 {
     try
     {
         var syncFunctions = new SyncFunctions();
         syncFunctions.SyncData();
     }
     catch (Exception ex)
     {
     }
 }
예제 #4
0
 private void timer_Tick(object sender, EventArgs e)
 {
     try
     {
         timer.Interval = new TimeSpan(0, 1, 0);
         //timer.Stop();
         if (!string.IsNullOrEmpty(SyncFunctions.username))
         {
             using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
             {
                 var PendingBills = conn.Query <dynamic>("SELECT VCHRNO, JSON_DATA FROM tblSyncLog WHERE STATUS = 0");
                 foreach (dynamic bill in PendingBills)
                 {
                     if (bill.VCHRNO.Substring(0, 2) == "CN")
                     {
                         BillReturnViewModel model;
                         if (!string.IsNullOrEmpty(bill.JSON_DATA))
                         {
                             model = JsonConvert.DeserializeObject <BillReturnViewModel>(bill.JSON_DATA);
                         }
                         else
                         {
                             model = SyncFunctions.getBillReturnObject(bill.VCHRNO);
                         }
                         model.datetimeClient = DateTime.Now;
                         model.isrealtime     = false;
                         SyncFunctions.SyncSalesReturnData(model);
                     }
                     else
                     {
                         BillViewModel model;
                         if (!string.IsNullOrEmpty(bill.JSON_DATA))
                         {
                             model = JsonConvert.DeserializeObject <BillViewModel>(bill.JSON_DATA);
                         }
                         else
                         {
                             model = SyncFunctions.getBillObject(bill.VCHRNO);
                         }
                         model.datetimeClient = DateTime.Now;
                         model.isrealtime     = false;
                         SyncFunctions.SyncSalesData(model);
                     }
                     System.Threading.Thread.Sleep(100);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.GetBaseException().Message);
     }
 }
예제 #5
0
        public void SyncData(object sender, ElapsedEventArgs e)
        {
            Timer.Stop();
            try
            {
                EventLog.WriteEntry("Sync Started", EventLogEntryType.Information);

                var syncFunctions = new SyncFunctions();
                syncFunctions.SyncData();
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Error occured Started : " + ex.Message, EventLogEntryType.Error);
            }
            Timer.Start();
        }
예제 #6
0
        private void ExecuteSave(object obj)
        {
            string strSQL;
            string BillNo = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(Remarks))
                {
                    MessageBox.Show("Cannot issue Credit Note without Remarks. Please enter Remarks and try again.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        if (conn.ExecuteScalar <int>("SELECT COUNT(*) FROM ParkingSales WHERE RefBillNo = @RefBillNo", new { RefBillNo = InvoicePrefix + RefBillNo }, tran) > 0)
                        {
                            MessageBox.Show("Credit Note has already been issued on selected bill. Please enter another Bill No and try again.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Warning);
                            return;
                        }

                        BillNo = "CN" + GlobalClass.GetInvoiceNo("CN", tran);
                        strSQL = string.Format
                                 (
                            @"INSERT INTO ParkingSales (BillNo, TDate, TMiti, TTime, BILLTO, BILLTOADD, BILLTOPAN, Description, Amount, Discount, NonTaxable, Taxable, VAT, GrossAmount, PID, UID, SESSION_ID, FYID, TaxInvoice, RefBillNo, Remarks) 
                                    SELECT @BillNo, @TDATE, @TMITI, @TTIME, BILLTO, BILLTOADD, BILLTOPAN, Description, Amount, Discount, NonTaxable, Taxable, VAT, GrossAmount, PID, @UID, @SESSION_ID, @FYID, TaxInvoice, @RefBillNo, @Remarks FROM ParkingSales WHERE BillNo = @RefBillNo AND FYID = @FYID"
                                 );
                        int res = conn.Execute(strSQL, new
                        {
                            BillNo     = BillNo,
                            TDATE      = CurDate,
                            TMITI      = nepDate.CBSDate(CurDate),
                            TTIME      = CurTime,
                            UID        = GlobalClass.User.UID,
                            SESSION_ID = GlobalClass.Session,
                            FYID       = GlobalClass.FYID,
                            RefBillNo  = InvoicePrefix + RefBillNo,
                            Remarks    = Remarks
                        }, transaction: tran);


                        if (res > 0)
                        {
                            string strSqlDetails = string.Format
                                                   (
                                @"INSERT INTO ParkingSalesDetails (BillNo, FYID, PType, ProdId, [Description], Quantity, Rate, Amount, Discount, NonTaxable, Taxable, VAT, NetAmount, Remarks) 
                                    SELECT @BillNo, @FYID, PType, ProdId, Description, Quantity, Rate, Amount, Discount, NonTaxable, Taxable, VAT, NetAmount, Remarks FROM ParkingSalesDetails WHERE BillNo = @RefBillNo AND FYID = @FYID"
                                                   );
                            conn.Execute(strSqlDetails, new { BillNo = BillNo, FYID = GlobalClass.FYID, RefBillNo = InvoicePrefix + RefBillNo }, tran);
                            conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = @VNAME AND FYID = @FYID", new { VNAME = "CN", FYID = GlobalClass.FYID }, transaction: tran);
                            GlobalClass.SetUserActivityLog("Credit Note", "New", VCRHNO: BillNo);
                            SyncFunctions.LogSyncStatus(tran, BillNo, GlobalClass.FYNAME);
                            MessageBox.Show("Credit Note successfully saved.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        tran.Commit();
                        if (!string.IsNullOrEmpty(SyncFunctions.username))
                        {
                            SyncFunctions.SyncSalesReturnData(SyncFunctions.getBillReturnObject(BillNo), 1);
                        }
                    }
                    if (!string.IsNullOrEmpty(BillNo))
                    {
                        RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, ((char)27).ToString() + ((char)112).ToString() + ((char)0).ToString() + ((char)64).ToString() + ((char)240).ToString(), "Receipt");   //Open Cash Drawer
                        PrintBill(BillNo.ToString(), conn, "CREDIT NOTE");
                    }
                    ExecuteUndo(null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #7
0
        private async void ExecuteSave(object obj)
        {
            try
            {
                if (!VSales.TRNMODE && string.IsNullOrEmpty(VSales.BillTo))
                {
                    MessageBox.Show("Customer Name cannot be empty in Credit Sales.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }
                else if (VSDetailList.Count == 0)
                {
                    MessageBox.Show("Please add atleast one Voucher Type.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }
                if (MessageBox.Show("You are going to save current transation. Do you want to proceed?", MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }
                ParkingVouchers = new List <Voucher>();
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        VSales.TDate      = CurDate;
                        VSales.TTime      = CurTime;
                        VSales.UID        = GlobalClass.User.UID;
                        VSales.SESSION_ID = GlobalClass.Session;
                        VSales.TMiti      = nepDate.CBSDate(CurDate);
                        VSales.BillNo     = InvoicePrefix + GetInvoiceNo(InvoicePrefix);
                        VSales.FYID       = GlobalClass.FYID;
                        VSales.Save(tran);
                        foreach (TParkingSalesDetails PSD in VSDetailList)
                        {
                            PSD.BillNo = VSales.BillNo;
                            PSD.FYID   = VSales.FYID;
                            PSD.Save(tran);
                        }

                        conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = @VNAME AND FYID = @FYID", new { VNAME = InvoicePrefix, FYID = GlobalClass.FYID }, transaction: tran);
                        GlobalClass.SetUserActivityLog("Voucher Sales Invoice", "New", VCRHNO: VSales.BillNo, WorkDetail: "Bill No : " + VSales.BillNo);

                        SyncFunctions.LogSyncStatus(tran, VSales.BillNo, GlobalClass.FYNAME);
                        if (GenerateVoucher)
                        {
                            vp = new wVoucherPrintProgress()
                            {
                                DataContext = this
                            };
                            vp.Show();
                            await GenerateVouchers(tran);

                            vp.Hide();
                        }
                        tran.Commit();
                        if (!string.IsNullOrEmpty(SyncFunctions.username))
                        {
                            SyncFunctions.SyncSalesData(SyncFunctions.getBillObject(VSales.BillNo), 1);
                        }
                        MessageBox.Show("Vouchers Generated Successfully", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                        if (!(string.IsNullOrEmpty(VSales.BillTo) || CustomerList.Any(x => x.Name == VSales.BillTo)))
                        {
                            CustomerList.Add(new Party {
                                Name = VSales.BillTo, Address = VSales.BILLTOADD, PAN = VSales.BILLTOPAN
                            });
                        }
                    }
                    if (!string.IsNullOrEmpty(VSales.BillNo))
                    {
                        PrintBill(VSales.BillNo, true);
                        if (GenerateVoucher)
                        {
                            vp.Show();
                            await PrintVouchers(VSales.BillNo, true);

                            vp.Close();
                        }
                    }
                    //GenerateVouchers();

                    ExecuteUndo(null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #8
0
        private void ExecuteSave(object obj)
        {
            string  strSQL;
            decimal Taxable, VAT, Amount, Discount, NonTaxable, Rate, Quantity;
            string  BillNo = string.Empty;

            try
            {
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        //PIN.PID = conn.ExecuteScalar<int>("SELECT CurNo FROM tblSequence WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran);
                        PIN.PID     = Convert.ToInt32(GetInvoiceNo("PID", tran));
                        PIN.Barcode = string.Empty;
                        PIN.Save(tran);
                        POUT.PID = PIN.PID;
                        POUT.Save(tran);
                        if (POUT.CashAmount > 0)
                        {
                            BillNo     = InvoicePrefix + GetInvoiceNo(InvoicePrefix, tran);
                            Quantity   = POUT.ChargedHours;
                            Amount     = POUT.CashAmount / (1 + (GlobalClass.VAT / 100));
                            Rate       = Amount / Quantity;
                            Discount   = 0;
                            NonTaxable = 0;
                            Taxable    = Amount - (NonTaxable + Discount);
                            VAT        = Taxable * GlobalClass.VAT / 100;
                            TParkingSales PSales = new TParkingSales
                            {
                                BillNo      = BillNo,
                                TDate       = POUT.OutDate,
                                TMiti       = POUT.OutMiti,
                                TTime       = POUT.OutTime,
                                BillTo      = POUT.BILLTO,
                                BILLTOADD   = POUT.BILLTOADD,
                                BILLTOPAN   = POUT.BILLTOPAN,
                                Amount      = Amount,
                                Discount    = Discount,
                                NonTaxable  = NonTaxable,
                                Taxable     = Taxable,
                                VAT         = VAT,
                                GrossAmount = POUT.CashAmount,
                                PID         = POUT.PID,
                                UID         = POUT.UID,
                                SESSION_ID  = POUT.SESSION_ID,
                                FYID        = GlobalClass.FYID,
                                TaxInvoice  = TaxInvoice
                            };
                            PSales.Save(tran);
                            TParkingSalesDetails PSalesDetails = new TParkingSalesDetails
                            {
                                BillNo      = BillNo,
                                FYID        = GlobalClass.FYID,
                                Quantity    = Quantity,
                                Rate        = Rate,
                                Amount      = Amount,
                                Discount    = Discount,
                                NonTaxable  = NonTaxable,
                                Taxable     = Taxable,
                                VAT         = VAT,
                                NetAmount   = POUT.CashAmount,
                                ProdId      = 0,
                                Description = "Parking Charge",
                                PType       = 'P'
                            };
                            PSalesDetails.Save(tran);

                            conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran);
                            conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = @VNAME AND FYID = @FYID", new { VNAME = InvoicePrefix, FYID = GlobalClass.FYID }, transaction: tran);
                            GlobalClass.SetUserActivityLog("Exit", "New", VCRHNO: BillNo, WorkDetail: "PID : " + PIN.PID);
                            SyncFunctions.LogSyncStatus(tran, BillNo, GlobalClass.FYNAME);
                        }
                        tran.Commit();
                        if (!string.IsNullOrEmpty(SyncFunctions.username))
                        {
                            SyncFunctions.SyncSalesData(SyncFunctions.getBillObject(BillNo), 1);
                        }
                    }
                    if (!string.IsNullOrEmpty(BillNo))
                    {
                        if (!GlobalClass.NoRawPrinter)
                        {
                            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, ((char)27).ToString() + ((char)112).ToString() + ((char)0).ToString() + ((char)64).ToString() + ((char)240).ToString(), "Receipt");   //Open Cash Drawer
                        }
                        POutVMTouch.PrintBill(BillNo.ToString(), conn, (TaxInvoice) ? "TAX INVOICE" : "ABBREVIATED TAX INVOCE");
                        if (TaxInvoice)
                        {
                            POutVMTouch.PrintBill(BillNo.ToString(), conn, "INVOICE");
                        }
                    }
                    ExecuteUndo(null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }