private void btnMalfunctionReport_Click(object sender, EventArgs e) { MalfunctionReportModel malfunctionReportModel = new MalfunctionReportModel(); //NE ZABORAVI GA INICIALIZIRAT jer ce izbacit gresku //DataRow selectedDataRow = ((DataRowView)cmbTechnicianMal.SelectedItem).Row; //int technicianId = Convert.ToInt32(selectedDataRow["Tehnician_ID"]); TechnicianModel tech = new TechnicianModel(); if (cmbTechnicianMal.SelectedItem != null) { tech = (TechnicianModel)cmbTechnicianMal.SelectedItem; } //int technicianId = selectedDataRow.Id; int technicianId = tech.Id; //label84.Text = technicianId.ToString(); malfunctionReportModel.Id = orderId; malfunctionReportModel.MalfunctionTime = Convert.ToDateTime(txtMalTime.Text); malfunctionReportModel.MalfunctionTimeEnd = Convert.ToDateTime(txtMalTimeEnd.Text); malfunctionReportModel.StateCurrent = txtStateCurrentMal.Text; malfunctionReportModel.ActionsTaken = txtActionsTakenMal.Text; malfunctionReportModel.StateAfter = txtStateAfterMal.Text; malfunctionReportModel.StatusCompleted = "Y"; malfunctionReportModel.SpareMaterial = txtSpareMaterialMal.Text; TechnicianModel technician = new TechnicianModel(); technician.Id = technicianId; malfunctionReportModel.Technician = technician; //find id of ATM , send Atm through UpdateAtmComponent var malfunctionReport = this.orderService.GetMalfunctionReportByOrderId(orderId); //int atmId = malfunctionReport.ATM.Id; //ovo mi vraca false vidit zasto //vraca false jer je stavljeno no count u proceduri var flag = this.orderService.UpdateMalfunctionOrder(malfunctionReportModel); AtmComponentModel atmComponent = new AtmComponentModel(); if (cmbComponentsMal.SelectedIndex > -1) { atmComponent.SerialNumber = txtSerialComponentMal.Text; atmComponent.Description = txtDescriptionComponentMal.Text; atmComponent.Name = cmbComponentsMal.SelectedItem.ToString(); atmComponent.Status = "Y"; var flagMal = this.atmService.UpdateAtmComponent(malfunctionReport.ATM, atmComponent); } DataTable data = this.orderService.GetAllOrdersByDate(date); this.LoadDataGridView(data); }
public List <MalfunctionReportModel> GetAllMalfunctionsList() { using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); //Create Malfunction List List <MalfunctionReportModel> _malfunctionReport = new List <MalfunctionReportModel>(); try { cmd = new SqlCommand("procGetAllMalfunctionOrders", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); da.SelectCommand = cmd; da.Fill(dt); cmd.Connection.Close(); foreach (DataRow row in dt.Rows) { MalfunctionReportModel _malfunction = new MalfunctionReportModel(); _malfunction.Id = Convert.ToInt32(row["Order_ID"]); _malfunction.OrderDate = Convert.ToDateTime(row["Order_date"]); _malfunction.StatusCompleted = row["Order_status_completed"].ToString(); _malfunction.ATM.Id = Convert.ToInt32(row["Atm_ID"]); _malfunction.ATM.Name = row["Atm_name"].ToString(); _malfunction.ATM.Address = row["Atm_address"].ToString(); _malfunction.OrderType = row["Malfunction_type"].ToString(); _malfunction.StateCurrent = row["State_current"].ToString(); //_malfunction.ActionsTaken = row["Actions_taken"].ToString(); //_malfunction.StateAfter = row["State_after"].ToString(); _malfunction.SpareMaterial = row["Spare_material"].ToString(); _malfunction.Technician.Name = row["Name"].ToString(); _malfunction.Technician.Surname = row["Surname"].ToString(); _malfunction.Technician.Company = row["Company"].ToString(); _malfunctionReport.Add(_malfunction); } } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmd.Dispose(); //pl.MySQLConn.Close(); } return(_malfunctionReport); } }
public MalfunctionReportModel GetMalfunctionReportByOrderId(int orderId) { AtmService atmService = new AtmService(); MalfunctionReportModel malfunctionReport = new MalfunctionReportModel(); malfunctionReport = this.orderAccess.GetMalfunctionReportByOrderId(orderId); malfunctionReport.ATM = atmService.GetAtmData(malfunctionReport.ATM.Id); return(malfunctionReport); }
public MalfunctionReportModel GetMalfunctionReportByOrderId(int orderId) { MalfunctionReportModel _malfunction = new MalfunctionReportModel(); 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("procGetMalfunctionReportByOrder", 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(); _malfunction.Id = Convert.ToInt16(dt.Rows[0]["Order_ID"]); _malfunction.ATM.Id = Convert.ToInt16(dt.Rows[0]["Atm_ID"]); _malfunction.OrderDate = (DateTime)dt.Rows[0]["Order_date"]; _malfunction.MalfunctionTime = (DateTime)dt.Rows[0]["Malfunction_time"]; _malfunction.MalfunctionTimeEnd = (DateTime)dt.Rows[0]["Malfunction_time_end"]; _malfunction.StateCurrent = Convert.ToString(dt.Rows[0]["State_current"]); _malfunction.ActionsTaken = Convert.ToString(dt.Rows[0]["Actions_taken"]); _malfunction.StateAfter = Convert.ToString(dt.Rows[0]["State_after"]); _malfunction.SpareMaterial = Convert.ToString(dt.Rows[0]["Spare_material"]); 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(_malfunction); } }
public bool UpdateMalfunctionOrder(MalfunctionReportModel malfunctionModel) { using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter();//maknit var rowsAffected = 0; try { cmd = new SqlCommand("procUpdateMalfunctionOrder", con); cmd.Parameters.Add(new SqlParameter("@Order_ID", malfunctionModel.Id)); cmd.Parameters.Add(new SqlParameter("@Malfunction_time", malfunctionModel.MalfunctionTime)); cmd.Parameters.Add(new SqlParameter("@Malfunction_time_end", malfunctionModel.MalfunctionTimeEnd)); cmd.Parameters.Add(new SqlParameter("@State_current", malfunctionModel.StateCurrent)); cmd.Parameters.Add(new SqlParameter("@Actions_taken", malfunctionModel.ActionsTaken)); cmd.Parameters.Add(new SqlParameter("@State_after", malfunctionModel.StateAfter)); cmd.Parameters.Add(new SqlParameter("@Spare_material", malfunctionModel.SpareMaterial)); cmd.Parameters.Add(new SqlParameter("@Order_status_completed", malfunctionModel.StatusCompleted)); cmd.Parameters.Add(new SqlParameter("@Tehnician_ID", malfunctionModel.Technician.Id)); 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); } } }
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e) { MalfunctionReportModel malfunctionReport = this.orderService.GetMalfunctionReportByOrderId(orderId); int atmId = malfunctionReport.ATM.Id; DataTable atmDataTable = this.atmService.GetComponentByAtmId(atmId); foreach (DataRow row in atmDataTable.Rows) { //if (cmbCompanyMal.SelectedItem != null) //{ string comp = cmbComponentsMal.SelectedItem.ToString(); if (row["Component_name"].ToString().Contains(comp)) { txtSerialComponentMal.Text = row["Component_serial_number"].ToString(); txtDescriptionComponentMal.Text = row["Component_description"].ToString(); } //} }//end for each }
public bool UpdateMalfunctionOrder(MalfunctionReportModel malfunctionModel) { return(this.orderAccess.UpdateMalfunctionOrder(malfunctionModel)); }
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; } }