/// <summary> /// Method to get error order by order_id /// </summary> /// <returns>Data table</returns> public ErrorReportModel GetErrorReportByOrderId(int orderId) { AtmService atmService = new AtmService(); ErrorReportModel errorReport = new ErrorReportModel(); errorReport = this.orderAccess.GetErrorReportByOrderId(orderId); errorReport.ATM = atmService.GetAtmData(errorReport.ATM.Id); return(errorReport); }
public ErrorReportModel GetErrorReportByOrderId(int orderId) { //string test = "2018-01-01"; //DateTime dTime = DateTime.ParseExact(test, "yyyy-MM-dd", CultureInfo.InvariantCulture); DataTable data = new DataTable(); ErrorReportModel _errorReport = new ErrorReportModel(); 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("procGetErrorReportByOrder", 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(); _errorReport.Id = Convert.ToInt16(dt.Rows[0]["Order_ID"]); _errorReport.ATM.Id = Convert.ToInt16(dt.Rows[0]["Atm_ID"]); _errorReport.OrderDate = (DateTime)dt.Rows[0]["Order_date"]; _errorReport.ErrorTime = (DateTime)dt.Rows[0]["Error_time"]; _errorReport.ErrorTime = (DateTime)dt.Rows[0]["Error_time_end"]; _errorReport.StateCurrent = Convert.ToString(dt.Rows[0]["State_current"]); _errorReport.ActionsTaken = Convert.ToString(dt.Rows[0]["Actions_taken"]); _errorReport.StateAfter = Convert.ToString(dt.Rows[0]["State_after"]); 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(_errorReport); } }
public bool UpdateErrorOrder(ErrorReportModel errorModel) { //string test = "2018-01-01"; //DateTime dTime = DateTime.ParseExact(test, "yyyy-MM-dd", CultureInfo.InvariantCulture); using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter();//maknit var rowsAffected = 0; try { cmd = new SqlCommand("procUpdateErrorOrder", con); cmd.Parameters.Add(new SqlParameter("@Order_ID", errorModel.Id)); cmd.Parameters.Add(new SqlParameter("@Error_time", errorModel.ErrorTime)); cmd.Parameters.Add(new SqlParameter("@Error_time_end", errorModel.ErrorTimeEnd)); cmd.Parameters.Add(new SqlParameter("@State_current", errorModel.StateCurrent)); cmd.Parameters.Add(new SqlParameter("@Actions_taken", errorModel.ActionsTaken)); cmd.Parameters.Add(new SqlParameter("@State_after", errorModel.StateAfter)); cmd.Parameters.Add(new SqlParameter("@Order_status_completed", errorModel.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 List <ErrorReportModel> GetAllErrorOrders() { using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); //Create Error List List <ErrorReportModel> _errorsReport = new List <ErrorReportModel>(); try { cmd = new SqlCommand("procGetAllErrorOrders", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); da.SelectCommand = cmd; da.Fill(dt); cmd.Connection.Close(); foreach (DataRow row in dt.Rows) { ErrorReportModel _error = new ErrorReportModel(); _error.Id = Convert.ToInt32(row["Order_ID"]); _error.OrderDate = Convert.ToDateTime(row["Order_date"]); _error.ATM.Id = Convert.ToInt32(row["Atm_ID"]); _error.ATM.Name = row["Atm_name"].ToString(); _error.ATM.Address = row["Atm_address"].ToString(); _error.OrderType = row["Error_type"].ToString(); _error.StateCurrent = row["State_current"].ToString(); _error.ActionsTaken = row["Actions_taken"].ToString(); _error.StateAfter = row["State_after"].ToString(); _errorsReport.Add(_error); } } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmd.Dispose(); //pl.MySQLConn.Close(); } return(_errorsReport); } }
private void btnSaveErrorReport_Click(object sender, EventArgs e) { ErrorReportModel errorReportModel = new ErrorReportModel(); errorReportModel.Id = orderId; errorReportModel.ErrorTime = Convert.ToDateTime(txtErrorTime.Text); errorReportModel.ErrorTimeEnd = Convert.ToDateTime(txtErrorTimeEnd.Text); errorReportModel.StateCurrent = txtStateCurrentError.Text; errorReportModel.ActionsTaken = txtActionsTakenError.Text; errorReportModel.StateAfter = txtStateAfterError.Text; errorReportModel.StatusCompleted = "Y"; var flag = this.orderService.UpdateErrorOrder(errorReportModel); DataTable data = this.orderService.GetAllOrdersByDate(date); this.LoadDataGridView(data); }
public ActionResult Error(ErrorReportModel form) { try { Guid trackingId = Guid.NewGuid(); AzureQueue.Enqueue(new AppErrorReport { AppId = form.AppId, AppVersion = form.AppVersion, Date = form.Date, ErrorDetail = form.ErrorDetail, InstallationId = form.InstallationId, UserMessage = form.UserMessage, TrackingId = trackingId, }); return(new HttpStatusCodeResult(200, trackingId.ToString())); } catch (Exception) { return(new HttpStatusCodeResult(500)); } }
public bool UpdateErrorOrder(ErrorReportModel errorModel) { return(this.orderAccess.UpdateErrorOrder(errorModel)); }
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; } }