Esempio n. 1
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value == null)
     {
         return(string.Empty);
     }
     if (((DateTime)value) < new DateTime(1882, 4, 13))
     {
         return("");
     }
     nepDate = new DateConverter(GlobalClass.TConnectionString);
     return(nepDate.CBSDate((DateTime)value));
 }
        private void ExecuteLoad(object obj)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    PIN.InDate = InDate;
                    PIN.InTime = InTime.ToString("hh:mm tt");
                    PIN.InMiti = nepDate.CBSDate(PIN.InDate);
                    PIN.VType  = VTypeList.First(x => x.VTypeID == PIN.VehicleType);

                    POUT.Rate_ID  = (int)conn.ExecuteScalar("SELECT RATE_ID FROM RATEMASTER WHERE IsDefault = 1");
                    POUT.OutDate  = _CurDate;
                    POUT.OutTime  = _CurTime;
                    POUT.OutMiti  = nepDate.CBSDate(POUT.OutDate);
                    POUT.Interval = GetInterval(PIN.InDate, POUT.OutDate, PIN.InTime, POUT.OutTime);
                    POUT.PID      = PIN.PID;

                    CalculateParkingCharge(conn, PIN.InDate.Add(DateTime.Parse(PIN.InTime).TimeOfDay), POUT.OutDate.Add(DateTime.Parse(POUT.OutTime).TimeOfDay), POUT.Rate_ID, PIN.VehicleType);
                    POUT.CashAmount = POUT.ChargedAmount;
                    if (POUT.CashAmount > GlobalClass.AbbTaxInvoiceLimit)
                    {
                        TaxInvoice           = true;
                        CanChangeInvoiceType = false;
                    }
                    else
                    {
                        CanChangeInvoiceType = true;
                    }
                    FocusedElement = (short)Focusable.CashAmount;
                    PoleDisplay.WriteToDisplay(POUT.ChargedAmount, PoleDisplayType.AMOUNT);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
        private void ExecuteSave(object obj)
        {
            try
            {
                if (obj is VehicleType)
                {
                    Parking.VType       = obj as VehicleType;
                    Parking.VehicleType = Parking.VType.VTypeID;
                }
                if (GlobalClass.EnablePlateNo)
                {
                    if (string.IsNullOrEmpty(Parking.VType.PlateNo))
                    {
                        if (MessageBox.Show("Vehicle Plate No is not entered. Do you want to continue?", MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                        {
                            return;
                        }
                    }
                    Parking.PlateNo = Parking.VType.PlateNo;
                }
                DateTime ServerTime = nepDate.GetServerTime();
                Parking.InDate = ServerTime.Date;
                Parking.InMiti = nepDate.CBSDate(Parking.InDate);
                Parking.InTime = ServerTime.ToString("hh:mm:ss tt");
                using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    Conn.Open();
                    if (!string.IsNullOrEmpty(Parking.PlateNo) && Conn.ExecuteScalar <int>("SELECT COUNT(*) FROM ParkingInDetails PID LEFT JOIN ParkingOutDetails POD ON PID.PID = POD.PID AND PID.FYID = POD.FYID WHERE PID.PlateNo = @PlateNo AND POD.PID IS NULL", Parking) > 0)
                    {
                        MessageBox.Show("Vehicle plate no is already in parking", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        return;
                    }
                    using (SqlTransaction tran = Conn.BeginTransaction())
                    {
                        //Parking.PID = conn.ExecuteScalar<int>("SELECT CurNo FROM tblSequence WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran);
                        Parking.PID = Convert.ToInt32(GetInvoiceNo("PID", tran));

                        while (Conn.ExecuteScalar <int>("SELECT COUNT (*) FROM ParkingInDetails WHERE PID = @PID AND FYID = @FYID", new { PID = Parking.PID, FYID = GlobalClass.FYID }, tran) > 0)
                        {
                            Conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran);
                            Parking.PID = Conn.ExecuteScalar <int>("SELECT CurNo FROM tblSequence WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran);
                        }
                        Parking.Barcode = BarCode(tran);
                        if (Parking.Save(tran))
                        {
                            Conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran);
                            GlobalClass.SetUserActivityLog(tran, "Entrance", "New", WorkDetail: "PID : " + Parking.PID);
                            var pslip = new ParkingSlip {
                                PIN = Parking, CompanyName = GlobalClass.CompanyName, CompanyAddress = GlobalClass.CompanyAddress
                            };
                            pslip.Print();
                            tran.Commit();

                            MessageBox.Show("Entrance Success." + Environment.NewLine + "Barcode : " + Parking.Barcode + Environment.NewLine + "In Time : " + Parking.InMiti + " " + Parking.InTime, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                            Parking.VType.PlateNo = string.Empty;
                            ExecuteUndo(null);
                        }
                        else
                        {
                            MessageBox.Show("Entrance failed.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Number + " : " + ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
 private void txtFDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     txtFMiti.Text = nepDate.CBSDate(txtFDate.SelectedDate.Value);
 }
Esempio n. 7
0
        private void ExecuteSave(object obj)
        {
            string  strSql;
            string  CurMiti;
            string  BillNo;
            decimal Taxable, VAT, _Amount, Discount, NonTaxable;

            if (string.IsNullOrEmpty(Particulars))
            {
                MessageBox.Show("Please select particulars first.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            if (Amount <= 0)
            {
                MessageBox.Show("Amount must be greater than Zero", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            if (MessageBox.Show("You are about to save current transaction. Do you really want to proceed ?", "Save Transaction", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }
            string Message = string.Empty;

            try
            {
                CurMiti = nepDate.CBSDate(CurDate);
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        BillNo     = InvoicePrefix + GlobalClass.GetInvoiceNo(InvoicePrefix, tran);
                        _Amount    = Amount / (1 + (GlobalClass.VAT / 100));
                        Discount   = 0;
                        NonTaxable = 0;
                        Taxable    = _Amount - (NonTaxable + Discount);
                        VAT        = Taxable * GlobalClass.VAT / 100;

                        string 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, Remarks) 
                                    VALUES (@BillNo, @TDATE, @TMITI, @TTIME, @BILLTO, @BILLTOADD, @BILLTOPAN, 'Parking Charge', @Amount, @Discount, @NonTaxable, @Taxable, @VAT, @GrossAmount, @PID, @UID, @SESSION_ID, @FYID, @TaxInvoice, @Remarks)"
                                        );
                        conn.Execute(strSQL, new
                        {
                            BillNo      = BillNo,
                            TDATE       = CurDate.Date,
                            TMITI       = CurMiti,
                            TTIME       = CurTime,
                            BILLTO      = BillTo,
                            BILLTOADD   = BillToAdd,
                            BILLTOPAN   = BillToPan,
                            Amount      = _Amount,
                            Discount    = Discount,
                            NonTaxable  = NonTaxable,
                            Taxable     = Taxable,
                            VAT         = VAT,
                            GrossAmount = Amount,
                            PID         = 0,
                            UID         = GlobalClass.User.UID,
                            SESSION_ID  = GlobalClass.Session,
                            FYID        = GlobalClass.FYID,
                            TaxInvoice  = TaxInvoice,
                            Remarks     = Remarks
                        }, transaction: tran);
                        conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = @VNAME AND FYID = @FYID", new { VNAME = InvoicePrefix, FYID = GlobalClass.FYID }, transaction: tran);
                        tran.Commit();
                        ExecuteUndo(null);
                    }
                    RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, ((char)27).ToString() + ((char)112).ToString() + ((char)0).ToString() + ((char)64).ToString() + ((char)240).ToString(), "Receipt");
                    PrintBill(BillNo.ToString(), conn);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }