Beispiel #1
0
        private void savebutton_Click(object sender, EventArgs e)
        {
            Store    aStore    = new Store();
            StoreDAO aStoreDao = new StoreDAO();

            aStore = aStoreDao.GetStoreByItemId(ItemId);
            Transaction1 aTransaction1 = new Transaction1();

            aTransaction1.ItemName        = aStore.ItemName;
            aTransaction1.TransactionType = transactiontypelebel.Text;
            aTransaction1.Amount          = Convert.ToDouble(quantitytextBox.Text) * aStore.UnitPrice;
            aTransaction1.Quantity        = Convert.ToDouble(quantitytextBox.Text);
            aTransaction1.ItemUnit        = aStore.Unit;
            aTransaction1.CauseOrPurpose  = purposeTextBox.Text.Trim();

            aStore.Quantity -= Convert.ToDouble(quantitytextBox.Text);
            if (aStore.Quantity >= 0)
            {
                aStoreDao.InsertTransaction(aTransaction1, CategoryId);

                string sr = aStoreDao.UpdateStore(aStore);
                MessageBox.Show(sr);
                if (sr == "Insert Sucessfully")
                {
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Not Enough quantity");
            }
        }
Beispiel #2
0
        private Transaction1 ReadToOrderTotalforProfit(IDataReader oReader)
        {
            Transaction1 aTransaction1 = new Transaction1();

            try
            {
                if (oReader["Order Date-Time"] != DBNull.Value)
                {
                    aTransaction1.Date = new DateTime(Int64.Parse(oReader["Order Date-Time"].ToString())).Date;
                }
            }
            catch (Exception)
            {
            }
            try
            {
                if (oReader["Total Paid(Inc. Vat)"] != DBNull.Value)
                {
                    aTransaction1.Amount = Convert.ToDouble(oReader["Total Paid(Inc. Vat)"].ToString());
                }
                //Total Paid(Inc. Vat)
            }
            catch (Exception)
            {
            }
            return(aTransaction1);
        }
Beispiel #3
0
        public IActionResult Create(IndexView model)
        {
            Transaction1 newTransaction = model.bank_transaction;

            newTransaction.user_id = model.user_transaction.user_id;


            model.user_transaction = _context.users
                                     .Include(u => u.transactions)
                                     .SingleOrDefault(user => user.user_id == newTransaction.user_id);

            _context.transactions.Add(newTransaction); // here you are adding the new Transaction 'newTransaction' to the transactions table in mysql
            newTransaction.current_balance = model.user_transaction.transactions.Sum(u => u.transaction_amount);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Transaction1", new { id = newTransaction.user_id }));
        }
Beispiel #4
0
        private Transaction1 ReadToTransactionforProfit(IDataReader aReader)
        {
            Transaction1 aTransaction1 = new Transaction1();

            try
            {
                aTransaction1.Date = Convert.ToDateTime(aReader["date"]);
            }
            catch (Exception)
            { }
            try
            {
                aTransaction1.Amount = Convert.ToDouble(aReader["amount"]);
            }
            catch (Exception)
            { }

            return(aTransaction1);
        }
Beispiel #5
0
 public void InsertOtherTransaction(Transaction1 aTransaction1, int categoryId)
 {
     try
     {
         DateTime aDateTime = DateTime.Now.Date;
         this.OpenConnection();
         string sqlComm = string.Format(SqlQueries.GetQuery(Query.InsertOtherTransaction), aTransaction1.ItemName,
                                        aTransaction1.Quantity, aTransaction1.ItemUnit, aTransaction1.Amount,
                                        aTransaction1.SupplierName, aTransaction1.TransactionType, aDateTime, categoryId, aTransaction1.CauseOrPurpose);
         this.ExecuteNonQuery(sqlComm);
     }
     catch (Exception ex)
     {
         //throw new Exception(ex.ToString());
     }
     finally
     {
         this.CloseConnection();
     }
 }
        //Payment
        public IActionResult Payment(string paymethod)
        {
            TempData["paymethod"] = paymethod;
            Bookings1 booking = new Bookings1();

            booking.Uid        = TempData["Uid"] != null ? (int)TempData["Uid"] : 7;
            booking.Cid        = (int)TempData["Cid"];
            booking.Hid        = (int)TempData["Hid"];
            booking.StartDate  = (DateTime)TempData["StartDate"];
            booking.EndDate    = (DateTime)TempData["EndDate"];
            booking.GuestCount = (int)TempData["GuestCount"];

            _db.Bookings1s.Add(booking);
            _db.SaveChanges();
            TempData["BookingId"] = _db.Bookings1s.Max(c => c.BookingId);

            Transaction1 transaction = new Transaction1
            {
                BookingId       = (int)TempData["BookingId"],
                TransactionDate = DateTime.Today,
                Amount          = "150",
                Paymethod       = (string)TempData["Paymethod"]
            };

            _db.Transaction1s.Add(transaction);
            _db.SaveChanges();
            TempData["Amount"] = transaction.Amount;
            int total_amount;

            if ((string)TempData["Type"] == "king")
            {
                total_amount = 180 * (int)TempData["Room"];
            }
            else
            {
                total_amount = 220 * (int)TempData["Room"];
            }
            TempData["Total_Amount"] = total_amount;

            return(View());
        }
Beispiel #7
0
        private void savebutton_Click(object sender, System.EventArgs e)
        {
            Store    aStore    = new Store();
            StoreDAO aStoreDao = new StoreDAO();

            aStore = aStoreDao.GetStoreByItemId(ItemId);
            Transaction1 aTransaction1 = new Transaction1();

            aTransaction1.ItemName        = aStore.ItemName;
            aTransaction1.TransactionType = "Purchase";
            aTransaction1.SupplierName    = supplierNamecomboBox.Text;
            aTransaction1.Amount          = Convert.ToDouble(amounttextBox.Text);
            aTransaction1.Quantity        = Convert.ToDouble(quantitytextBox.Text);
            aTransaction1.ItemUnit        = aStore.Unit;

            aStoreDao.InsertTransaction(aTransaction1, CategoryId);

            double newstore    = aStore.Amount + Convert.ToDouble(amounttextBox.Text);
            double newquantity = aStore.Quantity + Convert.ToDouble(quantitytextBox.Text);
            double unitprice   = 0;

            if (newquantity != 0)
            {
                unitprice = (newstore / newquantity);
            }
            else
            {
                unitprice = 0;
            }
            aStore.UnitPrice = unitprice;
            aStore.Quantity  = newquantity;
            string sr = aStoreDao.UpdateStore(aStore);

            MessageBox.Show(sr);
            if (sr == "Insert Sucessfully")
            {
                this.Close();
            }
        }
Beispiel #8
0
        public List <Transaction1> showAllData(long startDate, long endDate)
        {
            List <Transaction1> aTransactions = new List <Transaction1>();

            //CResult oResult = new CResult();
            //CSearchOrderInfo oOrderInfo = new CSearchOrderInfo();

            try
            {
                this.OpenConnection();
                string sqlCommand = "";
                sqlCommand = String.Format(SqlQueries.GetQuery(Query.GetOrderInfo), startDate.ToString(), endDate.ToString());
                //this.ExecuteNonQuery(sqlCommand);
                IDataReader oReader = this.ExecuteReader(sqlCommand);

                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        Transaction1 aTransaction1 = new Transaction1();
                        aTransaction1 = ReadToOrderTotalforProfit(oReader);
                        aTransactions.Add(aTransaction1);
                    }
                }

                //oResult.Data = oOrderInfo;
                //oResult.IsSuccess = true;
            }

            catch (Exception ex)
            {
            }
            finally
            {
                this.CloseConnection();
            }

            return(aTransactions);
        }
Beispiel #9
0
        public List <Transaction1> EmployeeTransactionReportBydate(DateTime fromDate, DateTime toDate)
        {
            List <Transaction1> aTransactions = new List <Transaction1>();

            try
            {
                this.OpenConnection();
                string      sqlComm = string.Format(SqlQueries.GetQuery(Query.EmployeeTransactionReportBydate), fromDate, toDate);
                IDataReader aReader = this.ExecuteReader(sqlComm);
                if (aReader != null)
                {
                    while (aReader.Read())
                    {
                        Transaction1 aTransaction1 = new Transaction1();
                        aTransaction1 = ReadToTransactionforProfit(aReader);
                        aTransactions.Add(aTransaction1);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(aTransactions);
        }
Beispiel #10
0
        private Transaction1 ReadToTransaction(IDataReader aReader)
        {
            Transaction1 aTransaction1 = new Transaction1();

            try
            {
                aTransaction1.TransactionId = Convert.ToInt32(aReader["transaction_id"]);
            }
            catch (Exception)
            {}
            try
            {
                aTransaction1.ItemName = (aReader["item_name"]).ToString();
            }
            catch (Exception)
            { }

            try
            {
                aTransaction1.SupplierName = (aReader["supplier"]).ToString();
            }
            catch (Exception)
            { }
            try
            {
                aTransaction1.TransactionType = (aReader["transaction_type"]).ToString();
            }
            catch (Exception)
            { }

            try
            {
                aTransaction1.Amount = Convert.ToDouble(aReader["amount"]);
            }
            catch (Exception)
            { }
            try
            {
                aTransaction1.Quantity = Convert.ToDouble(aReader["quantity"]);
            }
            catch (Exception)
            { }

            try
            {
                aTransaction1.ItemUnit = (aReader["unit"]).ToString();
            }
            catch (Exception)
            { }

            try
            {
                aTransaction1.Date = Convert.ToDateTime(aReader["date"]);
            }
            catch (Exception)
            { }

            try
            {
                aTransaction1.CauseOrPurpose = (aReader["Purpose"]).ToString();
            }
            catch (Exception)
            { }



            return(aTransaction1);
        }