Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtAmountPaid.Text.All(char.IsDigit) && txtChange.Text != "" && Double.Parse(txtChange.Text) >= 0)
            {
                //Save
                ReceiptReference receipt = new ReceiptReference();
                receipt.refID           = selectedID;
                receipt.refStatus       = "PAID";
                receipt.refPersonnelOut = currentUserID;
                receipt.refTimeCount    = lblTimeCount.Text;
                receipt.refPrice        = lblAmount.Text;
                receipt.refAmountPaid   = txtAmountPaid.Text;
                receipt.refAmountChange = txtChange.Text;
                receipt.refTimeOut      = txtTimeOut.Text;

                if (connect.updateReceiptReference(receipt))
                {
                    ParkingSlot dataToPass = new ParkingSlot();
                    dataToPass.slotIsAvailable = "1";
                    dataToPass.slotID          = (Convert.ToInt32(txtParkingNo.Text) - 100).ToString();
                    connect.updateParkingSpace(dataToPass);

                    MessageBox.Show("Saved Successfully!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Ooops Something went wrong!");
                }
            }
            else
            {
                MessageBox.Show("Invalid Amount! Please check your inputs.");
            }
        }
Example #2
0
        }//END OF CREATE VEHICLE INFO

        public Boolean createReceiptReference(ReceiptReference passedData)
        {
            bool     reqStatus        = false;
            DateTime dateTimeVariable = DateTime.Now;
            string   date             = dateTimeVariable.ToString("yyyy-MM-dd H:mm:ss");

            /*
             *  refBarcode
             *  refVehicleID
             *  refParkingID
             *  refTimeIn
             *  refPersonnelIn
             *  refStatus
             *  created_at
             */

            passedData.refBarcode     = passedData.refBarcode;
            passedData.refVehicleID   = passedData.refVehicleID;
            passedData.refParkingID   = passedData.refParkingID;
            passedData.refPersonnelIn = passedData.refPersonnelIn;
            passedData.refTimeIn      = date;
            passedData.refStatus      = "PENDING";
            passedData.created_at     = date;

            try
            {
                openConnection();
                sql = @"INSERT INTO tblreceiptreference SET refBarcode='" + passedData.refBarcode +
                      "', refVehicleID='" + passedData.refVehicleID +
                      "', refParkingID='" + passedData.refParkingID +
                      "', refPersonnelIn='" + passedData.refPersonnelIn +
                      "', refTimeIn='" + passedData.refTimeIn +
                      "', refStatus='" + passedData.refStatus +
                      "', created_at='" + passedData.created_at + "'";

                cmd = new MySqlCommand(sql, con);
                cmd.ExecuteNonQuery();

                reqStatus = true;
            }
            catch
            {
                reqStatus = false;
            }
            finally
            {
                con.Close();
            }

            return(reqStatus);
        }//END OF CREATE TRANSACTION
Example #3
0
        }//END OF READ ALL PENDING ACCOUNT

        public List <ReceiptReference> searchReceiptRefence_pending(string searchText)
        {
            searchText = Sanitize(searchText);

            try
            {
                openConnection();
                sql = @"SELECT * FROM tblreceiptreference WHERE (refBarcode LIKE '%" + searchText +
                      "%' OR 	refParkingID LIKE '%"+ searchText +
                      "%') AND refStatus='PENDING'";
                cmd = new MySqlCommand(sql, con);
                rd  = cmd.ExecuteReader();

                if (rd.HasRows)
                {
                    var listOfReceipt = new List <ReceiptReference>();

                    while (rd.Read())
                    {
                        var receipt = new ReceiptReference();

                        receipt.refID        = rd["refID"].ToString();
                        receipt.refBarcode   = rd["refBarcode"].ToString();
                        receipt.refParkingID = rd["refParkingID"].ToString();
                        receipt.refTimeIn    = rd["refTimeIn"].ToString();
                        receipt.refStatus    = rd["refStatus"].ToString();

                        listOfReceipt.Add(receipt);
                    }

                    return(listOfReceipt);
                }
                else
                {
                    Console.WriteLine("No data");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                con.Close();
            }

            return(null);
        }//END OF SEARCH FROM ALL PENDING ACCOUNT
Example #4
0
        }//END OF UPDATE TRANSACTION

        public List <ReceiptReference> readReceiptRefence_pending()
        {
            try
            {
                openConnection();
                sql = "SELECT * FROM tblreceiptreference WHERE refStatus='PENDING'";
                cmd = new MySqlCommand(sql, con);
                rd  = cmd.ExecuteReader();

                if (rd.HasRows)
                {
                    var listOfReceipt = new List <ReceiptReference>();

                    while (rd.Read())
                    {
                        var receipt = new ReceiptReference();

                        receipt.refID        = rd["refID"].ToString();
                        receipt.refBarcode   = rd["refBarcode"].ToString();
                        receipt.refParkingID = rd["refParkingID"].ToString();
                        receipt.refTimeIn    = rd["refTimeIn"].ToString();
                        receipt.refStatus    = rd["refStatus"].ToString();

                        listOfReceipt.Add(receipt);
                    }

                    return(listOfReceipt);
                }
                else
                {
                    Console.WriteLine("No data");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                con.Close();
            }

            return(null);
        }//END OF READ ALL PENDING ACCOUNT
Example #5
0
        }//END OF CREATE TRANSACTION

        public Boolean updateReceiptReference(ReceiptReference passedData)
        {
            bool reqStatus = false;

            passedData.refID           = passedData.refID;
            passedData.refStatus       = passedData.refStatus;
            passedData.refPersonnelOut = passedData.refPersonnelOut;
            passedData.refTimeCount    = passedData.refTimeCount;
            passedData.refPrice        = passedData.refPrice;
            passedData.refAmountPaid   = passedData.refAmountPaid;
            passedData.refAmountChange = passedData.refAmountChange;

            DateTime enteredDate = DateTime.Parse(passedData.refTimeOut);

            passedData.refTimeOut = enteredDate.ToString("yyyy-MM-dd H:mm:ss");

            try
            {
                openConnection();
                sql = @"UPDATE tblreceiptreference SET refStatus='" + passedData.refStatus +
                      "', refPersonnelOut='" + passedData.refPersonnelOut +
                      "', refTimeCount='" + passedData.refTimeCount +
                      "', refPrice='" + passedData.refPrice +
                      "', refAmountPaid='" + passedData.refAmountPaid +
                      "', refAmountChange='" + passedData.refAmountChange +
                      "', refTimeOut='" + passedData.refTimeOut +
                      "' WHERE refID='" + passedData.refID + "'";

                cmd = new MySqlCommand(sql, con);
                cmd.ExecuteNonQuery();

                reqStatus = true;
            }
            catch
            {
                reqStatus = false;
            }
            finally
            {
                con.Close();
            }

            return(reqStatus);
        }//END OF UPDATE TRANSACTION
Example #6
0
        public void receiptRefCreate()
        {
            VehicleInfo info = new VehicleInfo();

            info.vehicleOwner   = txtCustomer.Text;
            info.vehiclePlateNo = txtVehiclePlateNo.Text;

            foreach (var brandRef in currentDataBrand)
            {
                if (brandRef.brandName == cboVehicleBrand.Text)
                {
                    info.vehicleBrand = brandRef.brandID;
                    break;
                }
            }

            info.vehicleColor = txtVehicleColor.Text;

            if (connect.createVehicleInfo(info))
            {
                string lastInsertedID = connect.lastInsertedVehicleInfo();

                GenerateCode();

                ReceiptReference receiptRef = new ReceiptReference();
                receiptRef.refBarcode     = generatedCode;
                receiptRef.refPersonnelIn = this.currentUserID;
                receiptRef.refVehicleID   = lastInsertedID;
                receiptRef.refParkingID   = (Convert.ToInt32(selectedParkingID) - 100).ToString();

                ParkingSlot dataToPass = new ParkingSlot();
                dataToPass.slotIsAvailable = "0";
                dataToPass.slotID          = (Convert.ToInt32(selectedParkingID) - 100).ToString();
                connect.updateParkingSpace(dataToPass);

                if (connect.createReceiptReference(receiptRef))
                {
                    clearTransactionData();
                    //MessageBox.Show("Successfully Generated!");
                }
            }
        }