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 bool AddAtmComponent(AtmModel atm, AtmComponentModel atmComponent) { using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter();//maknit var rowsAffected = 0; try { //TO DO napravit storanu procc za update component cmd = new SqlCommand("procAddComponent", con); cmd.Parameters.Add(new SqlParameter("@Component_serial_number", atmComponent.SerialNumber)); cmd.Parameters.Add(new SqlParameter("@Component_name", atmComponent.Name)); cmd.Parameters.Add(new SqlParameter("@Component_description", atmComponent.Description)); cmd.Parameters.Add(new SqlParameter("@Component_status_ok", atmComponent.Status)); cmd.Parameters.Add(new SqlParameter("@Atm_ID", atm.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); } } }
public bool UpdateAtmComponent(AtmModel atm, AtmComponentModel atmComponent) { return(this.atmAccess.UpdateAtmComponent(atm, atmComponent)); }
public bool AddAtmComponent(AtmModel atm, AtmComponentModel atmComponent) { return(this.atmAccess.AddAtmComponent(atm, atmComponent)); }