private void btnSaveRefillReport_Click(object sender, EventArgs e) { //TO DO VALIDATE AND ERROR MSGBOXES RefillModel refillModel = new RefillModel(); refillModel.Id = orderId; refillModel.RefillTime = Convert.ToDateTime(txtRefillTime.Text); refillModel.RefillTimeEnd = Convert.ToDateTime(txtRefillTimeEnd.Text); refillModel.RefillNewBill100 = Convert.ToInt16(txtAtmRefillNewBill100.Text); refillModel.RefillNewBill200 = Convert.ToInt16(txtAtmRefillNewBill200.Text); refillModel.ReturnLocalBill100 = Convert.ToInt16(txtAtmRefillLocalBill100.Text); // ovo triba prominit krivo san napisa ime textboxa refillModel.ReturnLocalBill200 = Convert.ToInt16(txtAtmRefillLocalBill200.Text); // ovo triba prominit krivo san napisa ime textboxa refillModel.ReturnServerBill100 = Convert.ToInt16(txtAtmRefillServerBill100.Text); // i ovo triba prominit krivo san napisa ime textboxa refillModel.ReturnServerBill200 = Convert.ToInt16(txtAtmRefillServerBill200.Text); // i ovo triba prominit krivo san napisa ime textboxa refillModel.CashBill100 = Convert.ToInt16(txtAtmCashBill100.Text); refillModel.CashBill200 = Convert.ToInt16(txtAtmCashBill200.Text); refillModel.StatusCompleted = "Y"; // TO DO Spremi listice var flag = this.orderService.UpdateRefillOrder(refillModel); lblAtmRefillNewBill100.Text = refillModel.RefillNewBill100.ToString(); lblAtmRefillNewBill200.Text = refillModel.RefillNewBill200.ToString(); var data = this.orderService.GetAllOrdersByDate(date); this.LoadDataGridView(data); }
public RefillModel GetRefillReportByOrderId(int orderId) { //string test = "2018-01-01"; //DateTime dTime = DateTime.ParseExact(test, "yyyy-MM-dd", CultureInfo.InvariantCulture); RefillModel _refill = new RefillModel(); DataTable data = new DataTable(); using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); DataRow dataRow = null; try { cmd = new SqlCommand("procGetRefillReportByOrder", con); cmd.Parameters.Add(new SqlParameter("@Order_ID", orderId)); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); da.SelectCommand = cmd; da.Fill(dt); cmd.Connection.Close(); _refill.OrderDate = (DateTime)dt.Rows[0]["Order_date"]; _refill.ATM.Id = Convert.ToInt16(dt.Rows[0]["Atm_ID"]); _refill.RefillTime = (DateTime)dt.Rows[0]["Refill_time"]; _refill.RefillTimeEnd = (DateTime)dt.Rows[0]["Refill_time_end"]; _refill.RefillNewBill100 = Convert.ToInt32(dt.Rows[0]["Refill_new_bill_100"]); _refill.RefillNewBill200 = Convert.ToInt32(dt.Rows[0]["Refill_new_bill_200"]); _refill.ReturnLocalBill100 = Convert.ToInt32(dt.Rows[0]["Return_local_bill_100"]); _refill.ReturnLocalBill200 = Convert.ToInt32(dt.Rows[0]["Return_local_bill_200"]); _refill.ReturnServerBill100 = Convert.ToInt32(dt.Rows[0]["Return_server_bill_100"]); _refill.ReturnServerBill200 = Convert.ToInt32(dt.Rows[0]["Return_server_bill_100"]); _refill.CashBill100 = Convert.ToInt32(dt.Rows[0]["Cash_bill_100"]); _refill.CashBill200 = Convert.ToInt32(dt.Rows[0]["Cash_bill_200"]); dataRow = dt.Rows.Count > 0 ? dt.Rows[0] : null; } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmd.Dispose(); //pl.MySQLConn.Close(); } return(_refill); } }
public List <RefillModel> GetAllAtmsRefillOrders() { using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); //Create Error List List <RefillModel> _refillList = new List <RefillModel>(); try { cmd = new SqlCommand("procGetAllRefillOrders", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); da.SelectCommand = cmd; da.Fill(dt); cmd.Connection.Close(); foreach (DataRow row in dt.Rows) { RefillModel _refill = new RefillModel(); _refill.Id = Convert.ToInt32(row["Order_ID"]); _refill.OrderDate = Convert.ToDateTime(row["Order_date"]); //_refill.ATM.Name = row["Atm_status_completed"].ToString(); _refill.ATM.Id = Convert.ToInt32(row["Atm_ID"]); _refill.ATM.Name = row["Atm_name"].ToString(); _refill.ATM.Address = row["Atm_address"].ToString(); _refill.RefillNewBill100 = Convert.ToInt32(row["Refill_new_bill_100"]); _refill.RefillNewBill200 = Convert.ToInt32(row["Refill_new_bill_200"]); _refill.ReturnLocalBill100 = Convert.ToInt32(row["Return_local_bill_100"]); _refill.ReturnLocalBill200 = Convert.ToInt32(row["Return_local_bill_200"]); _refill.ReturnServerBill100 = Convert.ToInt32(row["Return_server_bill_100"]); _refill.ReturnServerBill200 = Convert.ToInt32(row["Return_server_bill_200"]); _refill.CashBill100 = Convert.ToInt32(row["Cash_bill_100"]); _refill.CashBill200 = Convert.ToInt32(row["Cash_bill_200"]); _refill.RefillTime = Convert.ToDateTime(row["Refill_time"]); _refill.RefillTime = Convert.ToDateTime(row["Refill_time_end"]); _refillList.Add(_refill); } } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmd.Dispose(); //pl.MySQLConn.Close(); } return(_refillList); } }
/// <summary> /// Method to get refill order by order_id /// </summary> /// <returns>Data table</returns> public RefillModel GetRefillReportByOrderId(int orderId) { AtmService atmService = new AtmService(); RefillModel refillReport = new RefillModel(); refillReport = this.orderAccess.GetRefillReportByOrderId(orderId); refillReport.ATM = atmService.GetAtmData(refillReport.ATM.Id); return(refillReport); }
public IActionResult Refill([FromBody] RefillModel refillModel) { var identity = HttpContext.User.Identity as ClaimsIdentity; IList <Claim> claim = identity.Claims.ToList(); var currentUserId = claim[0].Value; _refillBalanceRequestHandler.Handle(refillModel, currentUserId); return(Ok("Пополнение успешно")); }
public bool UpdateRefillOrder(RefillModel refillModel) { //string test = "2018-01-01"; //DateTime dTime = DateTime.ParseExact(test, "yyyy-MM-dd", CultureInfo.InvariantCulture); DataTable data = new DataTable(); using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter();//maknit var rowsAffected = 0; try { cmd = new SqlCommand("procUpdateRefillOrder", con); cmd.Parameters.Add(new SqlParameter("@Order_ID", refillModel.Id)); cmd.Parameters.Add(new SqlParameter("@Refill_time", refillModel.RefillTime)); cmd.Parameters.Add(new SqlParameter("@Refill_time_end", refillModel.RefillTimeEnd)); cmd.Parameters.Add(new SqlParameter("@Refill_new_bill_100", refillModel.RefillNewBill100)); cmd.Parameters.Add(new SqlParameter("@Refill_new_bill_200", refillModel.RefillNewBill200)); cmd.Parameters.Add(new SqlParameter("@Return_local_bill_100", refillModel.ReturnLocalBill100)); cmd.Parameters.Add(new SqlParameter("@Return_local_bill_200", refillModel.ReturnLocalBill200)); cmd.Parameters.Add(new SqlParameter("@Return_server_bill_100", refillModel.ReturnServerBill100)); cmd.Parameters.Add(new SqlParameter("@Return_server_bill_200", refillModel.ReturnServerBill200)); cmd.Parameters.Add(new SqlParameter("@Cash_bill_100", refillModel.CashBill100)); cmd.Parameters.Add(new SqlParameter("@Cash_bill_200", refillModel.CashBill200)); cmd.Parameters.Add(new SqlParameter("@Order_status_completed", refillModel.StatusCompleted)); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); rowsAffected = cmd.ExecuteNonQuery(); cmd.Connection.Close(); } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmd.Dispose(); //pl.MySQLConn.Close(); } if (rowsAffected > 0) { return(true); } else { return(false); } } }
public Task <AccountModel> Handle(RefillModel refillModel, string currentUserId) { var account = _accountService.GetAccountByHolder(currentUserId).Result; if (account == null) { throw new ArgumentException("Ваш счет не открыт, пополнение невозможно"); } refillModel.accountNumber = account.accountNumber; account.Balance += refillModel.amount; return(_transactionsService.UpdateAccountBalance(account)); }
public async Task <IActionResult> Post(RefillModel model, Guid accountId) { var command = model.Adapt <RefillCommand>(); command.UserId = CurrentUserId; command.AccountId = accountId; await _mediator.Send(command); await _mediator.Send(new LogActionCommand { AccountId = accountId, ActionType = ActionType.Refil }); return(Ok()); }
public bool UpdateRefillOrder(RefillModel refillModel) { return(this.orderAccess.UpdateRefillOrder(refillModel)); }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { //TO DO cmbComponentsMal.Enabled = false; txtSerialComponentMal.Enabled = false; txtDescriptionComponentMal.Enabled = false; if (dataGridView1.SelectedRows.Count == 0) { return; } label2.Text = dataGridView1[6, dataGridView1.SelectedRows[0].Index].Value.ToString(); if (dataGridView1[6, dataGridView1.SelectedRows[0].Index].Value.ToString().Trim() == "Kvar") { tabControl1.SelectedTab = tabPage5; MalfunctionReportModel malfunctionReport = new MalfunctionReportModel(); try { if (dataGridView1.SelectedRows.Count > 0) { //collect order id from datagridview string malfunctionOrderId = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); orderId = int.Parse(malfunctionOrderId); malfunctionReport = this.orderService.GetMalfunctionReportByOrderId(orderId); lblAtmNameMal.Text = malfunctionReport.ATM.Name.ToString(); lblAtmModelMal.Text = malfunctionReport.ATM.Model.ToString(); lblAtmSerialMal.Text = malfunctionReport.ATM.SerialNumber.ToString(); lblAtmAddressMal.Text = malfunctionReport.ATM.Address.ToString(); lblAtmLocationMal.Text = malfunctionReport.ATM.Location.ToString(); lblOrderDateMal.Text = malfunctionReport.OrderDate.ToString(); txtMalTime.Text = malfunctionReport.MalfunctionTime.ToString("hh:mm:ss"); txtMalTimeEnd.Text = malfunctionReport.MalfunctionTimeEnd.ToString("hh:mm:ss"); txtStateCurrentMal.Text = malfunctionReport.StateCurrent.ToString(); txtActionsTakenMal.Text = malfunctionReport.ActionsTaken.ToString(); txtStateAfterMal.Text = malfunctionReport.StateAfter.ToString(); txtSpareMaterialMal.Text = malfunctionReport.SpareMaterial.ToString(); } } catch (Exception) { throw; } } else if (dataGridView1[6, dataGridView1.SelectedRows[0].Index].Value.ToString().Trim() == "Punjenje") { tabControl1.SelectedTab = tabPage1; DataGridView dvg = (DataGridView)sender; RefillModel refillReport = new RefillModel(); try { if (dataGridView1.SelectedRows.Count > 0) { //Collect order id from datagridview string refillOrderId = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); orderId = int.Parse(refillOrderId); //Return Refill from database refillReport = this.orderService.GetRefillReportByOrderId(orderId); //Fill InterventionsView lblAtmName.Text = refillReport.ATM.Name.ToString(); lblAtmModel.Text = refillReport.ATM.Model.ToString(); //Calculate total sum int newBill100 = refillReport.RefillNewBill100; int newBill200 = refillReport.RefillNewBill200; int totalCash = newBill100 * 100 + newBill200 * 200; //Fill InterventionsView lblAtmTotalRefill.Text = totalCash.ToString(); lblAtmAccountingNumber.Text = refillReport.ATM.AccountingNumber.ToString(); lblAtmAddress.Text = refillReport.ATM.Address.ToString(); lblAtmLocation.Text = refillReport.ATM.Location.ToString(); lblAtmRefillNewBill100.Text = refillReport.RefillNewBill100.ToString(); lblAtmRefillNewBill200.Text = refillReport.RefillNewBill200.ToString(); lblOrderDate.Text = refillReport.OrderDate.ToString(); txtRefillTime.Text = refillReport.RefillTime.ToString("hh:mm:ss"); txtRefillTimeEnd.Text = refillReport.RefillTimeEnd.ToString("hh:mm:ss"); lblAtmRefillNewBill100.Text = refillReport.RefillNewBill100.ToString(); lblAtmRefillNewBill200.Text = refillReport.RefillNewBill200.ToString(); txtAtmRefillNewBill100.Text = refillReport.RefillNewBill100.ToString(); txtAtmRefillNewBill200.Text = refillReport.RefillNewBill200.ToString(); txtAtmRefillLocalBill100.Text = refillReport.ReturnLocalBill100.ToString(); txtAtmRefillLocalBill200.Text = refillReport.ReturnLocalBill200.ToString(); txtAtmRefillServerBill100.Text = refillReport.ReturnServerBill100.ToString(); txtAtmRefillServerBill200.Text = refillReport.ReturnServerBill200.ToString(); txtAtmCashBill100.Text = refillReport.CashBill100.ToString(); txtAtmCashBill200.Text = refillReport.CashBill200.ToString(); //calculate do atm has more or less cass that it suppose to int serverCash100 = refillReport.ReturnServerBill100; int returnedCash100 = refillReport.CashBill100; int serverCash200 = refillReport.ReturnServerBill200; int returnedCash200 = refillReport.CashBill200; int diff100 = serverCash100 - returnedCash100; int diff200 = serverCash200 - returnedCash200; //Fill InterventionsView txtServerCashDifference100.Text = diff100.ToString(); txtServerCashDifference200.Text = diff200.ToString(); } } catch (Exception) { throw; } } else if (dataGridView1[6, dataGridView1.SelectedRows[0].Index].Value.ToString().Trim() == "Greska") { tabControl1.SelectedTab = tabPage2; DataGridView dvg = (DataGridView)sender; ErrorReportModel errorReport = new ErrorReportModel(); try { if (dataGridView1.SelectedRows.Count > 0) { //collect order id from datagridview string errorOrderId = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); orderId = int.Parse(errorOrderId); errorReport = this.orderService.GetErrorReportByOrderId(orderId); lblAtmNameError.Text = errorReport.ATM.Name.ToString(); lblAtmModelError.Text = errorReport.ATM.Model.ToString(); lblAtmSerialError.Text = errorReport.ATM.SerialNumber.ToString(); lblAtmAddressError.Text = errorReport.ATM.Address.ToString(); lblAtmLocationError.Text = errorReport.ATM.Location.ToString(); lblOrderDateError.Text = errorReport.OrderDate.ToString(); txtErrorTime.Text = errorReport.ErrorTime.ToString("hh:mm:ss"); txtErrorTimeEnd.Text = errorReport.ErrorTimeEnd.ToString("hh:mm:ss"); txtStateCurrentError.Text = errorReport.StateCurrent.ToString(); txtActionsTakenError.Text = errorReport.ActionsTaken.ToString(); txtStateAfterError.Text = errorReport.StateAfter.ToString(); } } catch (Exception) { throw; } } else if (dataGridView1[6, dataGridView1.SelectedRows[0].Index].Value.ToString().Trim() == "Zadržana kartica") { tabControl1.SelectedTab = tabPage3; } }