/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CCalib_std</returns> internal List <CCalib_std> PopulateObjectsFromReader(IDataReader dataReader) { List <CCalib_std> list = new List <CCalib_std>(); while (dataReader.Read()) { CCalib_std businessObject = new CCalib_std(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(CCalib_std businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_calib_std_Insert"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_idcalib_std", businessObject.Idcalib_std); sqlCommand.Parameters["p_idcalib_std"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters["p_idcalib_std"].Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.AddWithValue("p_idcalib", businessObject.Idcalib); sqlCommand.Parameters["p_idcalib"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters.AddWithValue("p_absorbance", businessObject.Absorbance); sqlCommand.Parameters["p_absorbance"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_absorbance_previus", businessObject.Absorbance_previus); sqlCommand.Parameters["p_absorbance_previus"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_concentration", businessObject.Concentration); sqlCommand.Parameters["p_concentration"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_idset_calibs", businessObject.Idset_calibs); sqlCommand.Parameters["p_idset_calibs"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_idtemplate_method", businessObject.Idtemplate_method); sqlCommand.Parameters["p_idtemplate_method"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_idsolution_interm", businessObject.Idsolution_interm); sqlCommand.Parameters["p_idsolution_interm"].NpgsqlDbType = NpgsqlDbType.Integer; MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.Idcalib_std = Convert.ToInt64(sqlCommand.Parameters["p_idcalib_std"].Value); return(true); } catch (Exception ex) { throw new Exception("CCalib_std::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CCalib_std business object</returns> public CCalib_std SelectByPrimaryKey(CCalib_stdKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_calib_std_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_idcalib_std", NpgsqlDbType.Bigint, 8, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idcalib_std)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CCalib_std businessObject = new CCalib_std(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CCalib_std::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CCalib_std businessObject, IDataReader dataReader) { businessObject.Idcalib_std = dataReader.GetInt64(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idcalib_std.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idcalib.ToString()))) { businessObject.Idcalib = dataReader.GetInt64(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idcalib.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Absorbance.ToString()))) { businessObject.Absorbance = dataReader.GetDecimal(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Absorbance.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Absorbance_previus.ToString()))) { businessObject.Absorbance_previus = dataReader.GetDecimal(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Absorbance_previus.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Concentration.ToString()))) { businessObject.Concentration = dataReader.GetDecimal(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Concentration.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idset_calibs.ToString()))) { businessObject.Idset_calibs = dataReader.GetInt32(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idset_calibs.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idtemplate_method.ToString()))) { businessObject.Idtemplate_method = dataReader.GetInt32(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idtemplate_method.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idsolution_interm.ToString()))) { businessObject.Idsolution_interm = dataReader.GetInt32(dataReader.GetOrdinal(CCalib_std.CCalib_stdFields.Idsolution_interm.ToString())); } }
public void SaveCalibs(CSolution_interm pSolution_interm) { solution_interm = pSolution_interm; Date_init = Convert.ToDateTime(solution_interm.Date_begin); Date_end = Convert.ToDateTime(solution_interm.Date_end); UserSign = Comun.GetUser(); DateSign = Comun.GetDate(); //poner como historico la actual grupo de calibraciones CSet_calibs oSet_calib = oModCalibStd.GetSet_CalibBy(solution_interm.Idsolution_interm, idtemplate_method); if (oSet_calib != null) { oSet_calib.Last_calib = false; new CSet_calibsFactory().Update(oSet_calib); } // --- guardar la nueva calibración oSet_calib = new CSet_calibs(); oSet_calib.Idset_calibs = 0; oSet_calib.Idtemplate_method = idtemplate_method; oSet_calib.Idsolution_interm = solution_interm.Idsolution_interm; oSet_calib.Datesign = Comun.GetDate(); oSet_calib.Usersign = Comun.GetUser(); oSet_calib.Last_calib = true; bool result_set_calib = new CSet_calibsFactory().Insert(oSet_calib); // --- guardar estandares de calibración if (result_set_calib) { for (int i = 0; i < gvCalibStd.RowCount; i++) { CSet_calibsFactory faSet_calibs = new CSet_calibsFactory(); CCustomCalibStd customCalibStd = gvCalibStd.GetRow(i) as CCustomCalibStd; // --- guardar calibración CCalib_stdFactory faCalib_std = new CCalib_stdFactory(); CCalib_std oCalib_std = new CCalib_std(); oCalib_std = new CCalib_std(); oCalib_std.Idcalib = customCalibStd.Idcalib; oCalib_std.Absorbance = customCalibStd.Absorbance; oCalib_std.Concentration = customCalibStd.Concentration; oCalib_std.Idset_calibs = oSet_calib.Idset_calibs; oCalib_std.Idsolution_interm = solution_interm.Idsolution_interm; oCalib_std.Idtemplate_method = idtemplate_method; bool result_std = false; if (!(result_std = faCalib_std.Update(oCalib_std))) result_std = faCalib_std.Insert(oCalib_std); if (result_std) gvCalibStd.SetRowCellValue(i, gcCal_Idcalib_std, oCalib_std.Idcalib_std); } } }
public void SaveCalibs(CSolution_interm pSolution_interm) { solution_interm = pSolution_interm; Date_init = Convert.ToDateTime(solution_interm.Date_begin); Date_end = Convert.ToDateTime(solution_interm.Date_end); UserSign = Comun.GetUser(); DateSign = Comun.GetDate(); //poner como historico la actual grupo de calibraciones CSet_calibs oSet_calib = oModCalibStd.GetSet_CalibBy(solution_interm.Idsolution_interm, idtemplate_method); if (oSet_calib != null) { oSet_calib.Last_calib = false; new CSet_calibsFactory().Update(oSet_calib); } // --- guardar la nueva calibración oSet_calib = new CSet_calibs(); oSet_calib.Idset_calibs = 0; oSet_calib.Idtemplate_method = idtemplate_method; oSet_calib.Idsolution_interm = solution_interm.Idsolution_interm; oSet_calib.Datesign = Comun.GetDate(); oSet_calib.Usersign = Comun.GetUser(); oSet_calib.Last_calib = true; bool result_set_calib = new CSet_calibsFactory().Insert(oSet_calib); // --- guardar estandares de calibración if (result_set_calib) { for (int i = 0; i < gvCalibStd.RowCount; i++) { CSet_calibsFactory faSet_calibs = new CSet_calibsFactory(); CCustomCalibStd customCalibStd = gvCalibStd.GetRow(i) as CCustomCalibStd; // --- guardar calibración CCalib_stdFactory faCalib_std = new CCalib_stdFactory(); CCalib_std oCalib_std = new CCalib_std(); oCalib_std = new CCalib_std(); oCalib_std.Idcalib = customCalibStd.Idcalib; oCalib_std.Absorbance = customCalibStd.Absorbance; oCalib_std.Concentration = customCalibStd.Concentration; oCalib_std.Idset_calibs = oSet_calib.Idset_calibs; oCalib_std.Idsolution_interm = solution_interm.Idsolution_interm; oCalib_std.Idtemplate_method = idtemplate_method; bool result_std = false; if (!(result_std = faCalib_std.Update(oCalib_std))) { result_std = faCalib_std.Insert(oCalib_std); } if (result_std) { gvCalibStd.SetRowCellValue(i, gcCal_Idcalib_std, oCalib_std.Idcalib_std); } } } }
private void ucSignCalibStd_OnSign(bool login) { if (login) { if (oGroup_solution != null) { // --- guardar calibraciones, grupo1, grupo2 CSet_methods_calibFactory faSet_methods_calib = new CSet_methods_calibFactory(); CSet_calibsFactory faSet_calib = new CSet_calibsFactory(); CCalib_stdFactory faCalib_std = new CCalib_stdFactory(); foreach (CCustomCalibStd item in LstAllCalibs) { CSet_calibsFactory faSet_calibs = new CSet_calibsFactory(); // --- recuperar fila modificada CSet_calibs oSet_calib = faSet_calibs.GetByPrimaryKey(new CSet_calibsKeys(item.Idset_calibs)); if (oSet_calib == null) { oSet_calib = new CSet_calibs(); oSet_calib.Idset_calibs = 0; oSet_calib.Idtemplate_method = item.Idtemplate_method; oSet_calib.Idset_calibs = item.Idset_calibs; } oSet_calib.Idgroup_solution = oGroup_solution.Idgroup_solution; bool result_set_calib = false; // --- grupo de calibración if (!(result_set_calib = faSet_calibs.Update(oSet_calib))) { result_set_calib = faSet_calibs.Insert(oSet_calib); } if (result_set_calib) { // --- guardar calibración CCalib_std oCalib_std = new CCalib_std(); oCalib_std = faCalib_std.GetByPrimaryKey(new CCalib_stdKeys(item.Idcalib_std)); if (oCalib_std == null) { oCalib_std = new CCalib_std(); } oCalib_std.Idcalib_std = 0; oCalib_std.Absorbance_previus = item.Absorbance; oCalib_std.Concentration = item.Concentration; oCalib_std.Idcalib = item.Idcalib; oCalib_std.Idcalib_std = item.Idcalib_std; oCalib_std.Idset_calibs = oSet_calib.Idset_calibs; if (!faCalib_std.Update(oCalib_std)) { faCalib_std.Insert(oCalib_std); } } } this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else { } }
private void ucSignCalibStd_OnSign(bool login) { if (login) { if (oGroup_solution != null) { // --- guardar calibraciones, grupo1, grupo2 CSet_methods_calibFactory faSet_methods_calib = new CSet_methods_calibFactory(); CSet_calibsFactory faSet_calib = new CSet_calibsFactory(); CCalib_stdFactory faCalib_std = new CCalib_stdFactory(); foreach (CCustomCalibStd item in LstAllCalibs) { CSet_calibsFactory faSet_calibs = new CSet_calibsFactory(); // --- recuperar fila modificada CSet_calibs oSet_calib = faSet_calibs.GetByPrimaryKey(new CSet_calibsKeys(item.Idset_calibs)); if (oSet_calib == null) { oSet_calib = new CSet_calibs(); oSet_calib.Idset_calibs = 0; oSet_calib.Idtemplate_method = item.Idtemplate_method; oSet_calib.Idset_calibs = item.Idset_calibs; } oSet_calib.Idgroup_solution = oGroup_solution.Idgroup_solution; bool result_set_calib = false; // --- grupo de calibración if (!(result_set_calib = faSet_calibs.Update(oSet_calib))) result_set_calib = faSet_calibs.Insert(oSet_calib); if (result_set_calib) { // --- guardar calibración CCalib_std oCalib_std = new CCalib_std(); oCalib_std = faCalib_std.GetByPrimaryKey(new CCalib_stdKeys(item.Idcalib_std)); if (oCalib_std == null) oCalib_std = new CCalib_std(); oCalib_std.Idcalib_std = 0; oCalib_std.Absorbance_previus = item.Absorbance; oCalib_std.Concentration = item.Concentration; oCalib_std.Idcalib = item.Idcalib; oCalib_std.Idcalib_std = item.Idcalib_std; oCalib_std.Idset_calibs = oSet_calib.Idset_calibs; if (!faCalib_std.Update(oCalib_std)) faCalib_std.Insert(oCalib_std); } } this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else { } }