public List <RoleModel> getRole(int option) { try { DBResource newConnection = new DBResource(); List <RoleModel> listModel = new List <RoleModel>(); RoleModel RoleModel; using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString())) { string query = "dbo.GetRole " + option + ""; SqlCommand cmd = new SqlCommand(query, myConnection); myConnection.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { RoleModel = new RoleModel(); RoleModel.role = dr["role"].ToString(); listModel.Add(RoleModel); } myConnection.Close(); } } return(listModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// Add a new resource for save purpose /// </summary> /// <param name="s">The Stream data</param> /// <param name="key">The key associated with this resource</param> public void AddResource(Stream s, String key) { DBResource res = new DBResource(s, key); m_newResources.Add(key, res); m_loadedResources.Add(key, res); }
public bool SavePatientComp(PatientComplaintModel model) { try { DBResource newConnection = new DBResource(); newConnection.DBOpen(); SqlCommand comm = new SqlCommand(); comm.Connection = DBResource.conn; comm.CommandText = "dbo.SavePatientComplaint"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@consultaton_id", model.ConsultatonId); comm.Parameters.AddWithValue("@geid", model.geid); comm.Parameters.AddWithValue("@empname", model.EmpName); comm.Parameters.AddWithValue("@complaints", model.Complaints); comm.Parameters.AddWithValue("@created_date", model.CreatedDate); comm.Parameters.AddWithValue("@created_by", model.CreatedBy); comm.Parameters.AddWithValue("@medicine", model.Medicine); comm.Parameters.AddWithValue("@isAgree", model.Agree); comm.Parameters.AddWithValue("@company", model.Company); comm.ExecuteNonQuery(); newConnection.DBClose(); return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Unique constructor /// </summary> /// <param name="interiorTable"></param> /// <param name="interiorResource"></param> /// <param name="brandsTable"></param> /// <param name="brandsResource"></param> /// <param name="carColorsTable"></param> /// <param name="interiorSetId"></param> public InteriorSetDialog(DB interiorTable, DBResource interiorResource, DB brandsTable, DBResource brandsResource, DB carColorsTable, string interiorSetId) { InitializeComponent(); _InteriorTable = interiorTable; _BrandsTable = brandsTable; _InteriorSetId = interiorSetId; _InteriorResource = interiorResource; _BrandsResource = brandsResource; _CarColorsTable = carColorsTable; try { Cursor = Cursors.WaitCursor; _InitializeContents(); } catch (Exception ex) { MessageBoxes.ShowError(null, ex); } finally { Cursor = Cursors.Default; } }
public bool validateUserInformation(UsersModel UsersModel) { DBResource newConnection = new DBResource(); using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString())) { string query = "dbo.CheckUserAccount '" + UsersModel.usercode + "','" + UsersModel.userpass + "','" + UsersModel.role + "'"; SqlCommand cmd = new SqlCommand(query, myConnection); myConnection.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { clsGlobal.lblrole = dr["role"].ToString().Trim(); clsGlobal.usercode = dr["user_code"].ToString().Trim(); clsGlobal.LastName = dr["last_name"].ToString().Trim(); clsGlobal.FirstName = dr["first_name"].ToString().Trim(); clsGlobal.lblprivilege = dr["privilege"].ToString().Trim(); return(true); } } myConnection.Close(); return(false); } } }
public bool SaveConsultation(ConsultationModel model) { try { DBResource newConnection = new DBResource(); newConnection.DBOpen(); SqlCommand comm = new SqlCommand(); comm.Connection = DBResource.conn; comm.CommandText = "dbo.SaveConsultation"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@consultaton_id", model.ConsultatonId); comm.Parameters.AddWithValue("@member_code", model.MemberCOde); comm.Parameters.AddWithValue("@time_in", model.TimeIn); comm.Parameters.AddWithValue("@time_out", model.TimeOut); comm.Parameters.AddWithValue("@complaints", model.Complaints); comm.Parameters.AddWithValue("@medicine", model.Medicine); comm.Parameters.AddWithValue("@quantity", model.Quantity); comm.Parameters.AddWithValue("@disposition", model.Disposition); comm.Parameters.AddWithValue("@diag_code", model.DiagCode); comm.Parameters.AddWithValue("@created_by", model.CreatedBy); comm.Parameters.AddWithValue("@created_date", model.CreatedDate); comm.ExecuteNonQuery(); newConnection.DBClose(); return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Returns final resource value from specified cell. /// Does not support cross reference still. /// </summary> /// <param name="cell">Cell to get value</param> /// <param name="topicResource">Resource file to get values (when valueType = ValueInResource)</param> /// <returns></returns> public static string GetResourceValueFromCell(DB.Cell cell, DBResource topicResource) { string result; // According to value type... switch (cell.valueType) { case DB.ValueType.ReferenceL: case DB.ValueType.ValueInResource: case DB.ValueType.ValueInResourceH: // Corresponding value must be found into resource file DBResource.Entry currentEntry = topicResource.GetEntryFromId(cell.value); result = currentEntry.value; break; default: result = cell.value; break; } // Failsafe operation if (result == null) { result = DatabaseConstants.DEFAULT_RESOURCE_VALUE; Log.Info("WARNING ! Resource with code " + cell.value + " was not found in " + topicResource.CurrentTopic + "-" + topicResource.CurrentCulture + ". Please fix it!"); } return(result); }
/// <summary> /// Initializes identifier reference according to specified color resource /// </summary> /// <param name="colorsResource"></param> /// <param name="interiorColorsResource"></param> public static void InitIdReference(DBResource colorsResource, DBResource interiorColorsResource) { // Is init needed ? if (!_IsIdReady && colorsResource != null && interiorColorsResource != null) { // Initializes reverse color reference : parsing resource if provided foreach (DBResource.Entry anotherEntry in colorsResource.EntryList) { if (anotherEntry.isValid && !anotherEntry.isComment) { if (!_IdByCodeReference.ContainsKey(anotherEntry.value)) { _IdByCodeReference.Add(anotherEntry.value, anotherEntry.id.Id); } } } // Interior foreach (DBResource.Entry anotherEntry in interiorColorsResource.EntryList) { if (anotherEntry.isValid && !anotherEntry.isComment) { if (!_IdByCodeReference.ContainsKey(anotherEntry.value)) { _IdByCodeReference.Add(anotherEntry.value, anotherEntry.id.Id); } } } // OK ! _IsIdReady = true; } }
public bool TestWithDigitalInput(EngineData.DI[] detections, out Dictionary <EngineData.DI, int> testResult) { var validation = true; var builder = new StringBuilder(); testResult = new Dictionary <EngineData.DI, int>(); var error = ""; foreach (var DI in detections) { var result = ReadDI(DI); if (!result) { validation = false; builder.Append(Enum.GetName(typeof(EngineData.DI), DI) + " = " + result + " Wanted = true" + Environment.NewLine); testResult.Add(DI, 1); DBResource?.Result_SaveResult(DBResource.JobID, result, true, "", "", ResultSubCategory.Mechanical_DimensionControl, ResultUnit.Bool, ""); } else { testResult.Add(DI, 0); DBResource?.Result_SaveResult(DBResource.JobID, result, false, "", "", ResultSubCategory.Mechanical_DimensionControl, ResultUnit.Bool, ""); } } error = builder.ToString(); NewInternalErrorText?.Invoke(CycleId, error); return(validation); }
/// <summary> /// Checks specified topic in loaded data then returns eventual issues /// </summary> /// <param name="topic"></param> /// <returns></returns> private IEnumerable <DatabaseFixer.Corruption> _CheckTopic(DB.Topic topic) { Collection <DatabaseFixer.Corruption> returnedIssues = new Collection <DatabaseFixer.Corruption>(); if (topic != DB.Topic.None) { // Getting data and resource DB dbTopic = _LoadedData[topic][0] as DB; DBResource dbResource = _LoadedData[topic][1] as DBResource; if (dbTopic == null || dbResource == null) { throw new Exception("Invalid topic can't be loaded: " + topic); } // Values foreach (DB.Entry anotherEntry in dbTopic.Entries) { // Structure checks _CheckStructure(dbTopic, anotherEntry, returnedIssues); foreach (DB.Cell anotherCell in anotherEntry.cells) { // According to data type... switch (anotherCell.valueType) { case DB.ValueType.PrimaryKey: // Check disabled break; case DB.ValueType.Reference: _CheckReferenceValue(topic, anotherCell, returnedIssues); break; case DB.ValueType.ReferenceL: _CheckResourceValue(topic, anotherCell, null, returnedIssues); break; case DB.ValueType.ValueInResourceH: _CheckResourceValue(topic, anotherCell, dbResource, returnedIssues); break; case DB.ValueType.ValueInResource: _CheckResourceValue(topic, anotherCell, dbResource, returnedIssues); break; case DB.ValueType.BitField: // Check disabled break; default: break; } } } } return(returnedIssues); }
/// <summary> /// Main constructor /// </summary> /// <param name="defaultChallenges"></param> /// <param name="housesResource"></param> /// <param name="isSelectMode">true to allow track selection, else false</param> public OriginalTracksDialog(Collection <DFE> defaultChallenges, DBResource housesResource, bool isSelectMode) { InitializeComponent(); _DefaultChallenges = defaultChallenges; _HousesResource = housesResource; _IsSelectMode = isSelectMode; _InitializeContents(); }
private bool SaveCalibrationResult(CalibrationMeasurement caliber, string traceNr, int WSID, byte SubWS, double measuredValue, double calibrationError) { if (DBResource != null) { return(DBResource.Calibration_SaveMeasurement(Int64.Parse(traceNr), WSID, SubWS, caliber.ID_DefaultValue, measuredValue, caliber.NominalValue, calibrationError, caliber.Name)); } else { return(true); } }
/// <summary> /// Main constructor /// </summary> /// <param name="dbTopic"></param> /// <param name="entryId"></param> /// <param name="columnId"></param> /// <param name="dbResource"></param> /// <param name="linkedRes"></param> public MiniResourceEditorDialog(DB dbTopic, int entryId, int columnId, DBResource dbResource, string linkedRes) { InitializeComponent(); _DbTopic = dbTopic; _DbResource = dbResource; _ResourceId = linkedRes; _ColumnId = columnId; _EntryId = entryId; _InitializeContents(); }
public bool TestWithAnalogInput(EngineData.AI[] detections, out Dictionary <EngineData.AI, int> testResult, ResultUnit unit) { var validation = true; testResult = new Dictionary <EngineData.AI, int>(); var builder = new StringBuilder(); var error = ""; var index = 0; var adjustments = DBResource?.Calibration_GetLastAdjustments(WSID, 1); //Check Analog Inputs foreach (var AI in detections) { var adjustment = adjustments?.Find(a => a.Name == Enum.GetName(typeof(EngineData.AI), AI)); if (adjustment == null) { adjustment = new CalibrationAdjustment { OffSet = 0 }; } var realTimeValue = Math.Round(ReadAI(AI) - adjustment.OffSet, 2); var measure = DBResource?.MeasureLimits.Find(m => m.MeasureName == Enum.GetName(typeof(EngineData.AI), AI)); if (measure != null) { if (realTimeValue > measure.MinValue && realTimeValue < measure.MaxValue) { testResult.Add(AI, 0); DBResource?.Result_SaveResult(DBResource.JobID, realTimeValue, measure.MinValue, measure.MaxValue, "", "", ResultSubCategory.Mechanical_DimensionControl, unit, ""); } else { testResult.Add(AI, 1); validation = false; builder.Append(Enum.GetName(typeof(EngineData.AI), detections[index]) + " -> " + " [" + measure.MinValue + " < " + realTimeValue + " < " + measure.MaxValue + "]" + Environment.NewLine); DBResource?.Result_SaveResult(DBResource.JobID, realTimeValue, measure.MinValue, measure.MaxValue, "", "", ResultSubCategory.Mechanical_DimensionControl, ResultUnit.V, ""); } } index++; } error = builder.ToString(); NewInternalErrorText?.Invoke(CycleId, error); return(validation); }
public List <OMReportModel> RetrieveReport(string datefrom, string dateto) { try { DBResource newConnection = new DBResource(); List <OMReportModel> listOMReport = new List <OMReportModel>(); OMReportModel OMReport; using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString())) { string query = "dbo.GenerateOMReport '" + Convert.ToDateTime(datefrom).ToShortDateString() + "','" + Convert.ToDateTime(dateto).ToShortDateString() + "'"; SqlCommand cmd = new SqlCommand(query, myConnection); myConnection.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { OMReport = new OMReportModel(); OMReport.Employee_id = dr["Employee_id"].ToString(); OMReport.Employee_Name = dr["Employee_Name"].ToString(); OMReport.created_date = Convert.ToDateTime(dr["date"]).ToShortDateString(); OMReport.time_in = Convert.ToDateTime(dr["time_in"]); OMReport.time_out = Convert.ToDateTime(dr["time_out"]); OMReport.Age = dr.GetInt32(dr.GetOrdinal("age")); OMReport.gender = dr["gender"].ToString(); OMReport.complaint1 = dr["complaint1"].ToString(); OMReport.complaint2 = dr["complaint2"].ToString(); OMReport.complaint3 = dr["complaint3"].ToString(); OMReport.Medicine1 = dr["Medicine1"].ToString(); OMReport.quantity1 = dr["quantity1"].ToString(); OMReport.Medicine2 = dr["Medicine2"].ToString(); OMReport.quantity2 = dr["quantity2"].ToString(); OMReport.Medicine3 = dr["Medicine3"].ToString(); OMReport.quantity3 = dr["quantity3"].ToString(); OMReport.disposition = dr["disposition"].ToString(); OMReport.diagnosis = dr["Diagnosis"].ToString(); listOMReport.Add(OMReport); } } } myConnection.Close(); } return(listOMReport); } catch (Exception ex) { throw ex; } }
public void ReadResourceFile_ShouldGetAllEntries() { //Given string fileName = FileTesting.CreateFileFromResource("TDUModdingLibraryTests.Resources.TDU_Achievements.fr", Path.Combine(_tempPath, ResourceFile)); //When DBResource dbResource = TduFile.GetFile(fileName) as DBResource; //Then Assert.NotNull(dbResource); Assert.AreEqual(DB.Culture.FR, dbResource.CurrentCulture); Assert.AreEqual(DB.Topic.Achievements, dbResource.CurrentTopic); Assert.AreEqual(253, dbResource.EntryList.Count); }
/// <summary> /// Returns name of specified brand by querying database /// </summary> /// <param name="brandReference"></param> /// <param name="brandsTable"></param> /// <param name="brandsResource"></param> /// <returns></returns> public static string GetBrandName(string brandReference, DB brandsTable, DBResource brandsResource) { string returnedName = ""; if (!string.IsNullOrEmpty(brandReference) && brandsTable != null && brandsResource != null) { DB.Cell brandNameCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(_NAME_BRANDS_DB_COLUMN, brandsTable, brandReference)[0]; returnedName = DatabaseHelper.GetResourceValueFromCell(brandNameCell, brandsResource); } return(returnedName); }
public BitmapImage GetBitmapImageFromKeyRes(String key) { DBResource res = m_windowData.GetResource(key); if (res != null) { BitmapImage img = new BitmapImage(); img.BeginInit(); img.StreamSource = new MemoryStream(res.Data); img.EndInit(); return(img); } return(null); }
/// <summary> /// Loads a particular topic and its resource to fix it. To fix an already loaded database, just set Data property and do not use this method. /// </summary> /// <param name="dbTopic"></param> /// <param name="dbResource"></param> public static void LoadTopic(DB dbTopic, DBResource dbResource) { if (dbTopic != null && dbResource != null) { // Data init if needed if (_Data == null) { _Data = new Dictionary <DB.Topic, TduFile[]>(); } DB.Topic currentTopic = dbTopic.CurrentTopic; _Data.Remove(currentTopic); _Data.Add(currentTopic, new TduFile[] { dbTopic, dbResource }); } }
public bool SaveEmployeeExcel() { try { DBResource newConnection = new DBResource(); VIEW.frmProgress obj = new VIEW.frmProgress(); obj.Show(); for (int i = 0; i <= EmployeeCount - 1; i++) { Application.DoEvents(); newConnection.DBOpen(); SqlCommand comm = new SqlCommand(); comm.Connection = DBResource.conn; comm.CommandText = "dbo.SaveListOfEmployee"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@GEID", listMemModel[i].GEID); comm.Parameters.AddWithValue("@CostCenter", listMemModel[i].CostCenter); comm.Parameters.AddWithValue("@LegalVehicle", listMemModel[i].LegalVehicle); comm.Parameters.AddWithValue("@MemberType", listMemModel[i].MemberType); comm.Parameters.AddWithValue("@Membercode", listMemModel[i].Membercode); comm.Parameters.AddWithValue("@EmployeeName", listMemModel[i].EmployeeName); comm.Parameters.AddWithValue("@Sex", listMemModel[i].Sex); comm.Parameters.AddWithValue("@CS", listMemModel[i].CS); comm.Parameters.AddWithValue("@BirthDate", listMemModel[i].BirthDate); comm.Parameters.AddWithValue("@EffectiveDate", listMemModel[i].EffectiveDate); comm.Parameters.AddWithValue("@ValidityDate", listMemModel[i].ValidityDate); comm.Parameters.AddWithValue("@Relation", listMemModel[i].Relation); comm.Parameters.AddWithValue("@PlanDescription", listMemModel[i].PlanDescription); comm.Parameters.AddWithValue("@Area", listMemModel[i].Area); comm.ExecuteNonQuery(); comm.Dispose(); newConnection.DBClose(); SqlConnection.ClearAllPools(); obj.Text = "Total number of employees: " + i + " of " + EmployeeCount; } obj.Close(); obj.Hide(); return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Loads the whole specified topic for edit mode and returns corresponding TduFiles and EditTasks /// </summary> /// <param name="topic"></param> /// <param name="culture"></param> /// <param name="bnkFile"></param> /// <param name="rBnkFile"></param> /// <param name="returnedTasks"></param> /// <returns></returns> public static TduFile[] LoadTopicForEdit(DB.Topic topic, DB.Culture culture, BNK bnkFile, BNK rBnkFile, out EditHelper.Task[] returnedTasks) { TduFile[] returnedFiles = new TduFile[2]; returnedTasks = new EditHelper.Task[2]; if (bnkFile != null && bnkFile.Exists) { // Getting files string dbFilePath = bnkFile.GetPackedFilesPaths(DB.GetFileName(DB.Culture.Global, topic))[0]; returnedTasks[0] = EditHelper.Instance.AddTask(bnkFile, dbFilePath, true); if (culture != DB.Culture.Global && rBnkFile != null && rBnkFile.Exists) { string dbrFilePath = rBnkFile.GetPackedFilesPaths(DB.GetFileName(culture, topic))[0]; returnedTasks[1] = EditHelper.Instance.AddTask(rBnkFile, dbrFilePath, true); } // Loading these files DB main = TduFile.GetFile(returnedTasks[0].extractedFile) as DB; if (main == null || !main.Exists) { throw new Exception(topic + " main database loading failure."); } returnedFiles[0] = main; // Resource (optional) if (returnedTasks[1].isValid) { DBResource resource = TduFile.GetFile(returnedTasks[1].extractedFile) as DBResource; if (resource == null || !resource.Exists) { throw new Exception(string.Concat(topic, "-", culture, " resource database loading failure.")); } returnedFiles[1] = resource; } } return(returnedFiles); }
public List <PatientComplaintModel> getPatientComplaint() { try { DBResource newConnection = new DBResource(); List <PatientComplaintModel> listModel = new List <PatientComplaintModel>(); PatientComplaintModel PatientComplaintModel; using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString())) { string query = "dbo.GetMembersPerAccount"; SqlCommand cmd = new SqlCommand(query, myConnection); myConnection.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { PatientComplaintModel = new PatientComplaintModel(); PatientComplaintModel.ConsultatonId = dr["consultaton_id"].ToString() ?? " "; PatientComplaintModel.geid = dr["geid"].ToString() ?? " "; PatientComplaintModel.EmpName = dr["EmployeeName"].ToString() ?? " "; PatientComplaintModel.Complaints = dr["patient_complaints"].ToString() ?? " "; PatientComplaintModel.Medicine = dr["medicine"].ToString() ?? " "; PatientComplaintModel.CreatedDate = Convert.ToDateTime(dr["created_date"]); PatientComplaintModel.Company = dr["company"].ToString() ?? " "; PatientComplaintModel.membercode = dr["membercode"].ToString() ?? " "; PatientComplaintModel.diagnosis = dr["Diagnosis"].ToString() ?? " "; PatientComplaintModel.disposition = dr["Disposition"].ToString() ?? " "; listModel.Add(PatientComplaintModel); } myConnection.Close(); } } return(listModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// Checks cell value for specified resource and updates issues list /// </summary> /// <param name="topic"></param> /// <param name="cell"></param> /// <param name="dbResource"></param> /// <param name="issues"></param> /// <returns></returns> private void _CheckResourceValue(DB.Topic topic, DB.Cell cell, DBResource dbResource, Collection <DatabaseFixer.Corruption> issues) { if (dbResource == null) { // Resource from another topic if (cell.optionalRef != null) { DB.Topic referencedTopic = DB.TopicPerTopicId[cell.optionalRef]; // Is topic to be loaded ? TduFile[] databaseItems = _LoadedData[referencedTopic]; dbResource = databaseItems[1] as DBResource; if (dbResource == null) { throw new Exception("Unable to get database resource information for referenced topic: " + referencedTopic); } } } if (dbResource == null) { throw new Exception("Unable to get database resource information for topic: " + topic); } if (!dbResource.GetEntryFromId(cell.value).isValid) { // Report missing resource DatabaseFixer.Corruption newCorruption = new DatabaseFixer.Corruption { corruptedCell = cell, corruptedValue = cell.value, culture = dbResource.CurrentCulture, entryId = cell.entryIndex, kind = DatabaseFixer.CorruptionKind.MissingResource, referencedTopic = dbResource.CurrentTopic, topic = topic }; issues.Add(newCorruption); } }
public bool SaveConsultation(ConsultationModel model) { try { DBResource newConnection = new DBResource(); newConnection.DBOpen(); SqlCommand comm = new SqlCommand(); comm.Connection = DBResource.conn; comm.CommandText = "dbo.SaveConsultation"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@consultaton_id", model.ConsultatonId); comm.Parameters.AddWithValue("@GEID", model.GEID); comm.Parameters.AddWithValue("@member_code", model.MemberCode); comm.Parameters.AddWithValue("@time_in", model.TimeIn); comm.Parameters.AddWithValue("@time_out", model.TimeOut); comm.Parameters.AddWithValue("@complaints", model.Complaints); comm.Parameters.AddWithValue("@medicine", model.Medicine); comm.Parameters.AddWithValue("@disposition", model.Disposition); comm.Parameters.AddWithValue("@diag_code", model.DiagCode); if (Class.clsGlobal.lblrole == "Nurse") { comm.Parameters.AddWithValue("@update_by_nurse", model.CreatedBy); comm.Parameters.AddWithValue("@update_date_nurse", model.CreatedDate); } else { comm.Parameters.AddWithValue("@update_by_doctor", model.CreatedBy); comm.Parameters.AddWithValue("@update_date_doctor", model.CreatedDate); } comm.Parameters.AddWithValue("@role", Class.clsGlobal.lblrole); comm.ExecuteNonQuery(); newConnection.DBClose(); return(true); } catch (Exception ex) { throw ex; } }
public List <MemberModel> GetMember() { try { DBResource newConnection = new DBResource(); //newConnection.DBOpen(); List <MemberModel> listModel = new List <MemberModel>(); MemberModel memberModel; using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString())) { string query = "dbo.GetMembersPerAccount"; SqlCommand cmd = new SqlCommand(query, myConnection); myConnection.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { memberModel = new MemberModel(); memberModel.EmpID = dr["EMP_NO"].ToString(); memberModel.CompanyName = dr["ACCOUNT_NAME"].ToString(); memberModel.MemberCode = dr["MemberCode"].ToString(); memberModel.LName = dr["lastname"].ToString(); memberModel.FName = dr["firstname"].ToString(); memberModel.MName = dr["middle_name"].ToString(); memberModel.BDate = Convert.ToDateTime(dr["MEM_BDAY"]).ToString("dd/MM/yyyy"); //memberModel.Age = dr.GetInt32(dr.GetOrdinal("Age")); memberModel.Gender = dr["gender"].ToString(); listModel.Add(memberModel); } myConnection.Close(); } } return(listModel); } catch (Exception ex) { throw ex; } }
public bool RunSampleVerification(long traceNr, EngineData.AI[] analogDetections = null, ResultUnit unit = ResultUnit.V, EngineData.DI[] digitalDetections = null, bool[] wantedDigitalResult = null) { var analogResult = new Dictionary <EngineData.AI, int>(); var digitalResult = new Dictionary <EngineData.DI, int>(); if (analogDetections != null) { TestWithAnalogInput(analogDetections, out analogResult, unit); } else { var ais = (EngineData.AI[])Enum.GetValues(typeof(EngineData.AI)); TestWithAnalogInput(ais, out analogResult, unit); } if (digitalDetections != null) { if (wantedDigitalResult != null) { TestWithDigitalInput(digitalDetections, wantedDigitalResult, out digitalResult); } else { wantedDigitalResult = new bool[digitalDetections.Length]; for (int i = 0; i < wantedDigitalResult.Length; i++) { wantedDigitalResult[i] = true; } TestWithDigitalInput(digitalDetections, wantedDigitalResult, out digitalResult); } } if (DBResource != null) { return(DBResource.Samples_ValidateSampleTesting(traceNr)); } else { return(true); } }
/// <summary> /// Loads the whole specified topic in current database for read-only mode /// </summary> /// <param name="topic"></param> /// <param name="culture"></param> /// <returns>Array of database loaded TduFile. Index 0 is the main (encrypted) file, index 1 is the resource one</returns> public static TduFile[] LoadTopicForReadOnly(DB.Topic topic, DB.Culture culture) { TduFile[] returnedFiles = new TduFile[2]; // Loading BNKs string databaseFolder = LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database); string mainBnkFile = string.Concat(databaseFolder, DB.GetBNKFileName(DB.Culture.Global)); string resourceBnkFile = string.Concat(databaseFolder, DB.GetBNKFileName(culture)); BNK mainBnk = TduFile.GetFile(mainBnkFile) as BNK; BNK resourceBnk = TduFile.GetFile(resourceBnkFile) as BNK; // Getting read-only files if (mainBnk != null && resourceBnk != null) { string dbPackedFileName = DB.GetFileName(DB.Culture.Global, topic); string fileName = EditHelper.Instance.PrepareFile(mainBnk, mainBnk.GetPackedFilesPaths(dbPackedFileName)[0]); string dbrPackedFileName = DB.GetFileName(culture, topic); string resourceFileName = EditHelper.Instance.PrepareFile(resourceBnk, resourceBnk.GetPackedFilesPaths(dbrPackedFileName)[0]); // Loading these files DB main = TduFile.GetFile(fileName) as DB; DBResource resource = TduFile.GetFile(resourceFileName) as DBResource; if (main == null || !main.Exists) { throw new Exception(topic + " main database failure."); } if (resource == null || !resource.Exists) { throw new Exception(string.Concat(topic, "-", culture, " resource database failure.")); } // Filling array returnedFiles[0] = main; returnedFiles[1] = resource; } return(returnedFiles); }
private void btnChange_Click(object sender, EventArgs e) { Cursor.Current = Cursors.AppStarting; Properties.Settings.Default.User = txtUser.Text; Properties.Settings.Default.Password = txtPassword.Text; Properties.Settings.Default.ServerName = txtServer.Text; Properties.Settings.Default.DatabaseName = txtDatabase.Text; Properties.Settings.Default.Save(); DBResource newConnection = new DBResource(); if (newConnection.IsAvailable(newConnection.connectionString.ToString())) { MessageBox.Show("Database Settings successfully change.", "OCMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Cannot find database server.", "OCMS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Cursor.Current = Cursors.Default; }
public List <DiagnosisModel> getDiagnosis() { try { DBResource newConnection = new DBResource(); List <DiagnosisModel> listModel = new List <DiagnosisModel>(); DiagnosisModel diagnosisModel; using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString())) { string query = "dbo.GetDiagnosis"; SqlCommand cmd = new SqlCommand(query, myConnection); myConnection.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { diagnosisModel = new DiagnosisModel(); diagnosisModel.diag_desc = dr["diag_desc"].ToString(); diagnosisModel.diag_code = dr["diag_code"].ToString(); diagnosisModel.icd10_code = dr["icd10_code"].ToString(); diagnosisModel.icd10_4c = dr["icd10_4c"].ToString(); listModel.Add(diagnosisModel); } myConnection.Close(); } } return(listModel); } catch (Exception ex) { throw ex; } }
public bool SaveUsersInformation(UsersModel UsersModel) { try { int result; DBResource newConnection = new DBResource(); newConnection.DBOpen(); SqlCommand comm = new SqlCommand(); comm.Connection = DBResource.conn; comm.CommandText = "dbo.SaveUserInformation"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@LastName", UsersModel.lastname); comm.Parameters.AddWithValue("@FirstName", UsersModel.firstname); comm.Parameters.AddWithValue("@MiddleName", UsersModel.middlename); comm.Parameters.AddWithValue("@UserCode", UsersModel.usercode); comm.Parameters.AddWithValue("@UserPassword", UsersModel.userpass); comm.Parameters.AddWithValue("@Role", UsersModel.role); comm.Parameters.AddWithValue("@LicenseNo", UsersModel.licenseno); comm.Parameters.AddWithValue("@Privilege", UsersModel.privilege); comm.Parameters.AddWithValue("@active", UsersModel.active); result = comm.ExecuteNonQuery(); newConnection.DBClose(); if (result > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }