public ActionResult Index_Post() { try { ViewData["Message"] = " "; TransactionClass tranObj = new TransactionClass(); UpdateModel(tranObj); string con = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; SqlConnection sqlCon = new SqlConnection(con); sqlCon.Open(); SqlCommand sqlCmd = new SqlCommand("p_insert_transaction", sqlCon); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@DEBIT_ACCOUNT_NO", Session["Accountno"]); sqlCmd.Parameters.AddWithValue("@CREDIT_ACCOUNT_NO", tranObj.AccountNo); sqlCmd.Parameters.AddWithValue("@AMOUNT", tranObj.Amount); sqlCmd.ExecuteNonQuery(); sqlCon.Close(); ViewData["Message"] = " Transaction Successfull"; return(View()); } catch { ViewData["Message"] = " Transaction Failed"; return(View()); } }
public string AddTransactionQuery(int employeeID, TransactionClass cls, ref string recordID) { var column = ""; var updateRecord = ""; switch (cls) { case TransactionClass.Order: column = "OrderID"; recordID = String.IsNullOrEmpty(recordID) ? OrderID.DbValue() : recordID; updateRecord = String.Format("update [Order] set Paid = (select isnull(sum(Amount), 0) from Transactions where OrderID = {0}) where ID = {0}", recordID); break; case TransactionClass.Repair: column = "RepairID"; recordID = String.IsNullOrEmpty(recordID) ? RepairID.DbValue() : recordID; break; case TransactionClass.Warranty: column = "WarrantyID"; recordID = String.IsNullOrEmpty(recordID) ? WarrantyID.DbValue() : recordID; break; default: break; } var result = String.Format( @" insert into Transactions(EmployeeID, {0}, Method, Amount, SubmitDate, TransferDate) values ({1}, {2}, N'{3}', {4}, {5}, {6}) {7}", column, employeeID, recordID, Method, Amount, SubmitDate.DbValue(), TransferDate.DbValue(), updateRecord); return(result); }
private void lstNDDaMua_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { TransactionClass transactionObjTemp = (sender as ListBox).SelectedItem as TransactionClass; String mess = ""; if (transactionObjTemp.stop_time == null || transactionObjTemp.stop_time == "Đã xem hết") { mess = "Bạn có muốn xem lại nội dung này ?"; } else { mess = "Bạn có muốn xem tiếp nội dung này ?"; } if (MessageBox.Show(mess, "Thông Báo", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { enableProgressIndicator_For_Transaction(); this.getURL(transactionObjTemp.content_id); } else { } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public TransactionList Save(int userID, int employeeID, string employeeName, TransactionClass cls, string action) { QueryOutput queryOutput; string recordID = null; var query = String.Format("{0}{1}", AddTransactionQuery(employeeID, cls, ref recordID), GetQuery(cls, recordID)); return(new TransactionList(employeeName, RecordID, Query <Transaction>(new DbQuery(userID, employeeID, action, query, true, recordID), out queryOutput))); }
void client_list_transaction_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { string data = e.Result; this.responseResult = data; parseJSONTransactionList(this.responseResult); //ds = new ObservableCollection<TransactionClass>(); if (this.current_page == 1) { ds.Clear(); } if (this.numberTransaction > 0) { for (int i = 0; i < numberTransactionPerPage; i++) { transactionObj = new TransactionClass(); transactionObj = listTransaction[i]; string source_image = ""; if (fixCacheImage == true) { //source_image = imgCache.getImage_2(childCategoryObj.category_id); } else //Day la hoan thien nhat tuy nhien can thoi gian de fix data ( cache Image) { source_image = imgCache.getImage(transactionObj.content_picture_path); } ds.Add(new TransactionClass() { content_picture_path = source_image, transaction_id = transactionObj.transaction_id, transaction_date = transactionObj.transaction_date, transaction_value = transactionObj.transaction_value, stop_time = transactionObj.stop_time, content_id = transactionObj.content_id, content_name = transactionObj.content_name }); } this.lstNDDaMua.ItemsSource = ds; //disableProgressBar(); } else { ds.Add(new TransactionClass() { content_picture_path = "http", transaction_id = "Không có dữ liệu", transaction_date = "", transaction_value = "", stop_time = "", content_id = "", content_name = "" }); this.lstNDDaMua.ItemsSource = ds; //disableProgressBar(); } disableProgressIndicator(); } catch (WebException ex) { Debug.WriteLine(ex.Message); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public bool AddTransaction(MVCQutationModel quatationModel) { bool result = false; try { TransactionModel model = new TransactionModel(); model.CompanyId = (int)quatationModel.CompanyId; model.AccountTitle = "Accounts receivable"; int AccountId = CommonController.GetAcccountId(model); if (AccountId > 0) { AccountTransictionTable _TransactionTable = new AccountTransictionTable(); _TransactionTable.FK_AccountID = AccountId; _TransactionTable.Dr = quatationModel.SubTotal; _TransactionTable.Cr = 0; _TransactionTable.TransictionNumber = Guid.NewGuid().ToString(); _TransactionTable.TransictionRefrenceId = quatationModel.QutationID.ToString(); _TransactionTable.CreationTime = DateTime.Now.TimeOfDay; _TransactionTable.AddedBy = Convert.ToInt32(Session["LoginUserID"]); _TransactionTable.FK_CompanyId = quatationModel.CompanyId; _TransactionTable.TransictionType = "Dr"; _TransactionTable.FKPaymentTerm = null; _TransactionTable.TransictionDate = DateTime.Now; _TransactionTable.Description = "invoice Creating Time Transaction"; if (TransactionClass.PerformTransaction(_TransactionTable)) { result = true; model.AccountTitle = "Input VAT"; int AccountId1 = CommonController.GetAcccountId(model); _TransactionTable.FK_AccountID = AccountId1; _TransactionTable.Dr = quatationModel.TotalVat21 + quatationModel.TotalVat6; if (TransactionClass.PerformTransaction(_TransactionTable)) { result = true; model.AccountTitle = "Cash on hand"; int AccountId12 = CommonController.GetAcccountId(model); _TransactionTable.FK_AccountID = AccountId12; _TransactionTable.Cr = quatationModel.TotalAmount; _TransactionTable.Dr = 0; _TransactionTable.TransictionType = "Cr"; if (TransactionClass.PerformTransaction(_TransactionTable)) { result = true; } } } } } catch (Exception) { throw; } return(result); }
public VMTransaction() { Transaction = new TransactionClass(); //Transaction.ChangesSaved += Transaction_ChangesSaved; SaveChangesCommand = new SaveChangesCommand(Transaction); DeleteTransactionUserCommand = new RelayCommand(o => Transaction.Transaction.MultiuserManager.DeleteTransactionUser()); AddTransactionUserCommand = new RelayCommand(o => Transaction.Transaction.MultiuserManager.AddTransactionUser()); }
public ActionResult FundTransfer(long destinationAccountNo, int amount, string comment) { long accountNo = long.Parse(Session["accountNumber"].ToString()); try { CustomerClass obj = new CustomerClass(); TransactionClass obj1 = new TransactionClass(); if (accountNo == destinationAccountNo) { ViewBag.Error = "Source and destination account cant be same"; return(View()); } bool res = obj.checkAccount(destinationAccountNo); if (res) { int amt = obj.getAmount(accountNo); if (amt > amount) { obj.transferAdd(amount, destinationAccountNo); obj.transferSub(amount, accountNo); ViewBag.Success = "transferred " + amount + " successfully"; obj1.insTrans(accountNo, destinationAccountNo, amount, "FundTransfer", comment); ModelState.Clear(); } else { ViewBag.Error = "Insufficient Amount"; } } else { ViewBag.Error = "Destination Account not found"; } } catch (Exception exp) { ViewBag.Error = "Exception " + exp; } return(View()); }
private void buttonSave_Click(object sender, EventArgs e) { //MessageBox.Show("I am Clicked"); TransactionClass transaction = new TransactionClass(); transaction.TransactionType = labelSale.Text.Trim(); transaction.TransactioDate = DateTime.Now; transaction.SysUser = "******"; transaction.GrandTotal = decimal.Parse(labelGrandTotal.Text); transaction.TransactionDetails = dtTransaction; bool success = false; using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; bool w = transactionDAL.Insert_Transaction(transaction, out transactionID);//Error in this section for (int i = 0; i < dtTransaction.Rows.Count; i++) { int ProductID = int.Parse(dtTransaction.Rows[i][0].ToString()); //string ProductName = dtTransaction.Rows[i][1].ToString(); decimal Rate = decimal.Parse(dtTransaction.Rows[i][2].ToString()); decimal Quantity = decimal.Parse(dtTransaction.Rows[i][3].ToString()); decimal Discount = decimal.Parse(dtTransaction.Rows[i][4].ToString()); decimal Tax = decimal.Parse(dtTransaction.Rows[i][5].ToString()); decimal Total = decimal.Parse(dtTransaction.Rows[i][6].ToString()); TransactionDetails td = new TransactionDetails(); td.ProductID = ProductID; td.Rate = Rate; td.Quantity = Quantity; td.Discount = Discount; td.Tax = Tax; td.Total = Total; bool x = invDAL.Decrease_Inventory(ProductID, Quantity); //For Decreasing Product Quantity bool y = transactionDAL.Insert_TransactionDetails(td); success = w && x && y; // DO this after solving error //success = y; //Comment this after solving error } if (success == true) { scope.Complete(); MessageBox.Show("Sale Transaction Completed."); } else { MessageBox.Show("Sale Transaction Failed."); } } //Print Function Here //MessageBox.Show("Print Me"); }
public Transaction(TransactionClass transactionClass, DateTime dateTime, double userMoney, Currency userCurrency, Currency cashierCurrency, double cashierMoney, string user, string cashier) { TransactionClass = transactionClass; DateTime = dateTime; UserMoney = userMoney; UserCurrency = userCurrency; CashierCurrency = cashierCurrency; CashierMoney = cashierMoney; User = user; Cashier = cashier; }
public override string ToString() { string transaction; if (TransactionClass.Equals(TransactionClass.Buy)) { transaction = $"покупке {CashierMoney} {CashierCurrency.Name} за {UserMoney} {UserCurrency}"; } else { transaction = $"продаже {UserMoney} {UserCurrency} за {CashierMoney} {CashierCurrency.Name}"; } return($"Кассир {Cashier} {DateTime} провёл транзакцию пользователя {User} {transaction}"); }
public bool Insert_Transaction(TransactionClass transaction, out int transactionID) { //Out -->-1 transactionID = -1; //define the return value and set its default value to false bool isSuccess = false; //Step 1: Create SQL Connection SqlConnection conn = new SqlConnection(myconnstr); try { //Step 2: Write SQL Query string sql = "INSERT INTO tbl_Transaction (TransactionType,SysUser,GrandTotal,TransactionDate) VALUES (@TransactionType,@SysUser,@GrandTotal,@TransactionDate); SELECT @@IDENTITY;"; //Step 3: Craete SQL Command sql and conn SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@TransactionType", transaction.TransactionType); cmd.Parameters.AddWithValue("@SysUser", transaction.SysUser); cmd.Parameters.AddWithValue("@GrandTotal", transaction.GrandTotal); cmd.Parameters.AddWithValue("@TransactionDate", transaction.TransactioDate); //Step 4: Connection Open conn.Open(); //Step 5: Execute Command object o = cmd.ExecuteScalar();//Error Here //if inserted rows is greater than zero, //in this case, set success to true //otherwise, set success to false if (o != null) { transactionID = int.Parse(o.ToString()); isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { } finally { //Step 7: Close Connection conn.Close(); } return(isSuccess); }
public Transaction(TransactionClass cls, int employeeID, int recordID, string method, decimal amount, DateTime?transferDate = null) { EmployeeID = employeeID; switch (cls) { case TransactionClass.Order: OrderID = recordID; break; case TransactionClass.Repair: RepairID = recordID; break; case TransactionClass.Warranty: WarrantyID = recordID; break; default: break; } Method = method; Amount = amount; TransferDate = transferDate.HasValue ? transferDate.Value : DateTime.Now; SubmitDate = DateTime.Now; }
private static string GetQuery(TransactionClass cls, object id) { var column = ""; switch (cls) { case TransactionClass.Order: column = "OrderID"; break; case TransactionClass.Repair: column = "RepairID"; break; case TransactionClass.Warranty: column = "WarrantyID"; break; default: break; } var query = String.Format(" select t.*, e.Name as [EmployeeName] from Transactions t join Employee e on t.EmployeeID = e.ID where t.{0} = {1} order by t.ID desc", column, id); return(query); }
private void parseJSONTransactionList(String jsonTransactionList) { try { var transactionListJSONObj = JsonConvert.DeserializeObject <RootTransactionClass>(jsonTransactionList); if (transactionListJSONObj.success == true || transactionListJSONObj.type == "transaction") { this.total_transaction = Int32.Parse(transactionListJSONObj.total_quantity); listTransaction = new List <TransactionClass>(); foreach (var obj in transactionListJSONObj.items) { transactionObj = new TransactionClass(); transactionObj.transaction_id = "ID giao dịch : " + obj.transaction_id; transactionObj.transaction_date = "Thời gian : " + obj.transaction_date; transactionObj.transaction_value = "Giá mua : " + obj.transaction_value; if (obj.stop_time == null || obj.stop_time == "") { transactionObj.stop_time = "Đã xem hết"; } else { transactionObj.stop_time = "Thời điểm dừng : " + obj.stop_time; } transactionObj.content_picture_path = obj.content_picture_path; transactionObj.content_id = obj.content_id; transactionObj.content_name = obj.content_name; listTransaction.Add(transactionObj); } this.numberTransactionPerPage = Int16.Parse(transactionListJSONObj.quantity); this.numberTransaction = Int16.Parse(transactionListJSONObj.total_quantity); } else { transactionObj = new TransactionClass(); transactionObj.transaction_id = "Không có dữ liệu !"; this.numberTransactionPerPage = 0; this.numberTransaction = 0; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
Transaction CreateTransaction(TransactionClass transactionClass) { try { Transaction transaction = new Transaction( transactionClass, DateTime.Now, Double.Parse(userCurrencyTextBox.Text), ((Currency)userCurrencyListBox.SelectedItem), ((Currency)cashierCurrencyListBox.SelectedItem), 0, userTextBox.Text.Length == 0 ? throw new FormatException() : userTextBox.Text, cashierTextBox.Text.Length == 0 ? throw new FormatException() : cashierTextBox.Text ); return(transaction); } catch (Exception e) { ShowMessage("Failed to parse"); } return(null); }
public static int Available(int productID, int recordID, TransactionClass cls) { try { using (var con = Repo.DB.SKtimeManagement) { var table = ""; switch (cls) { case TransactionClass.Order: table = "[Order]"; break; case TransactionClass.Repair: table = "Repair"; break; case TransactionClass.Warranty: table = "Warranty"; break; default: break; } var query = String.Format( @"declare @warehouseID int = (select WarehouseID from {1} where ID = {2}) select sum(isnull(ip.Quantity, 0)) - isnull(( select sum(ep.Quantity) from ExportProduct ep left join Export e on e.ID = ep.ExportID and e.Removed = 0 and e.Status in (N'Đã xuất', N'Đã chuyển') where ep.Returned = 0 and ep.ProductID = p.ID and e.WarehouseID = w.ID), 0) as [Quantity] from Product p join ImportProduct ip on p.ID = ip.ProductID join Import i on i.ID = ip.ImportID and i.Status = 'active' join Warehouse w on w.Status = 'active' and w.ID = i.WarehouseID where p.Status = 'active' and p.ID = {0} and w.ID = @warehouseID group by p.ID, p.Code, p.Name, p.Image, p.Price, p.Point, w.Name, w.ID order by p.Name", productID, table, recordID); return(con.Query <int>(query).FirstOrDefault()); } } catch { } return(0); }
public static TransactionList Get(int userID, int employeeID, string employeeName, TransactionClass cls, int recordID, string action) { QueryOutput queryOutput; return(new TransactionList(employeeName, recordID, Query <Transaction>(new DbQuery(userID, employeeID, action, GetQuery(cls, recordID)), out queryOutput))); }
public static TransactionList Remove(int userID, int employeeID, string employeeName, int transactionID, int recordID, TransactionClass cls, string action) { QueryOutput queryOutput; var updateRecord = ""; if (cls == TransactionClass.Order) { updateRecord = String.Format("update [Order] set Paid = (select isnull(sum(Amount), 0) from Transactions where OrderID = {0}) where ID = {0}", recordID); } var query = String.Format( @"delete Transactions where ID = {0} {1} {2}", transactionID, updateRecord, GetQuery(cls, recordID)); return(new TransactionList(employeeName, recordID, Query <Transaction>(new DbQuery(userID, employeeID, action, query, true, recordID), out queryOutput))); }
//public static SortableSearchableBindingList<StockLocation> StockLocations //{ // get // { // SortableSearchableBindingList<StockLocation> objStockLocationList = new SortableSearchableBindingList<StockLocation>(); // StockLocation objStockLocation; // SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings(); // DataTable objDataTable = new DataTable(); // SqlDataAdapter objDataAdapter; // SqlCommand objSQLCommand; // string strSQL; // strSQL = QueryDefinitions.GetQuery("SelectStockRoomLocations"); // objSL8_WTF_DataBaseSettings.SQLConnection.Open(); // objSQLCommand = new SqlCommand(strSQL, objSL8_WTF_DataBaseSettings.SQLConnection); // objDataAdapter = new SqlDataAdapter(objSQLCommand); // objDataAdapter.Fill(objDataTable); // foreach (DataRow objRow in objDataTable.Rows) // { // objStockLocation = new StockLocation(); // objStockLocation.Location = objRow["loc"].ToString(); // objStockLocation.LocationDescription = objRow["description"].ToString(); // objStockLocation.LocationType = objRow["loc_type"].ToString()[0]; // objStockLocationList.Add(objStockLocation); // } // return objStockLocationList; // } //} //public static BindingList<ComboBoxItem> StockLocations //{ // get // { // string strSQL; // SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings(); // SqlCommand objSQLCommand; // SqlDataAdapter objDataAdapter; // DataTable objDataTable; // BindingList<ComboBoxItem> objBindingList; // objBindingList = new BindingList<ComboBoxItem>(); // objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings(); // strSQL = QueryDefinitions.GetQuery("SelectStockRoomLocations"); // objSL8_WTF_DataBaseSettings.SQLConnection.Open(); // objSQLCommand = new SqlCommand(strSQL, objSL8_WTF_DataBaseSettings.SQLConnection); // objDataAdapter = new SqlDataAdapter(objSQLCommand); // objDataTable = new DataTable(); // objDataAdapter.Fill(objDataTable); // if (objDataTable.Rows.Count > 0) // { // objBindingList = new BindingList<ComboBoxItem>(); // //objBindingList.Add(new ComboBoxItem { Text = "--- Select Carrier ---", Value = "0" }); // for (int intCounter = 0; intCounter < objDataTable.Rows.Count; intCounter++) // objBindingList.Add(new ComboBoxItem { Value = objDataTable.Rows[intCounter][0].ToString(), Text = objDataTable.Rows[intCounter][0].ToString() }); // return objBindingList; // } // else // return objBindingList; // } //} public bool Insert() { /*I used the command "GRANT INSERT ON [WTF_App].[dbo].[jobtran] TO WTFApp" to grant the insert priveleges * "REVOKE INSERT ON [WTF_App].[dbo].[jobtran] TO WTFApp" is the SQL to remove the privelege. * Note that I needed to make a new query in order for a successful execution; each time I tried to use an existing Query, it failed */ SortableSearchableBindingList <Operation> objOperationList = new SortableSearchableBindingList <Operation>(); SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings(); DataTable objDataTable = new DataTable(); SqlCommand objSQLCommand; string strSQL; int intCompleteOperation, intCloseJob; intCompleteOperation = CompleteOperation ? 1 : 0; intCloseJob = CloseJob ? 1 : 0; strSQL = QueryDefinitions.GetQuery("InsertIntoJobTran", new string[] { JobNumber, Suffix.ToString(), TransactionType.ToString().ToUpper(), DateTime.Now.ToString(), QtyComplete.ToString(), Operation.ToString(), QtyMoved.ToString(), Warehouse, Location.ToString(), TransactionClass.ToString().ToUpper(), Operation.WorkCenter, UserCode, intCompleteOperation.ToString(), intCloseJob.ToString(), NextOperation.ToString() }); objSL8_WTF_DataBaseSettings.SQLConnection.Open(); objSQLCommand = objSL8_WTF_DataBaseSettings.SQLConnection.CreateCommand(); objSQLCommand.CommandText = strSQL; if (objSQLCommand.ExecuteNonQuery() == 1) //the appropriate record was affected { return(true); } else { return(false); } }
public SaveChangesCommand(TransactionClass transaction) { this.transaction = transaction; }