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; }
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"); }
private void savebutton_Click(object sender, EventArgs e) { Store aStore=new Store(); StoreDAO aStoreDao=new StoreDAO(); aStore = aStoreDao.GetOtherStoreByItemId(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.InsertOtherTransaction(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.UpdateOtherStore(aStore); MessageBox.Show(sr); if(sr=="Insert Sucessfully") { this.Close(); } }
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; }
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; }
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; }
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; }
public void InsertTransaction(Transaction1 aTransaction1, int category) { try { DateTime aDateTime = DateTime.Now.Date; this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.InsertTransaction),aTransaction1.ItemName, aTransaction1.Quantity, aTransaction1.ItemUnit, aTransaction1.Amount, aTransaction1.SupplierName, aTransaction1.TransactionType,aDateTime,category); this.ExecuteNonQuery(sqlComm); } catch (Exception ex) { //throw new Exception(ex.ToString()); } finally { this.CloseConnection(); } }
public List<Transaction1> GetOtherTransactionBydateAndTransactionType(DateTime fromDate, DateTime toDate, string transactionType) { List<Transaction1> aTransactions = new List<Transaction1>(); try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.GetOtherTransactionBydateAndTransactionType), fromDate, toDate, transactionType); IDataReader aReader = this.ExecuteReader(sqlComm); if (aReader != null) { while (aReader.Read()) { Transaction1 aTransaction1 = new Transaction1(); aTransaction1 = ReadToTransaction(aReader); aTransactions.Add(aTransaction1); } } } catch (Exception) { } return aTransactions; }