public LogIn() { InitializeComponent(); DataConnectionClass.GetDatabaseData(); //data base should not be cleared ... Unless absolutely nessisary //DataConnectionClass.TestConn.ResetAllDatabaseTables(); }
/// <summary> /// /// </summary> /// <param name="layerPath"></param> /// <returns></returns> public MapLayer GetLayer(string layerPath) { if (!System.IO.File.Exists(layerPath)) return null; GeoDataset oGeoDataset = null; DataConnection oConn = new DataConnectionClass(); MapLayer oLayer = null; oConn.Database = System.IO.Path.GetDirectoryName(layerPath); if (oConn.Connect()) { oGeoDataset = oConn.FindGeoDataset(System.IO.Path.GetFileName(layerPath).Replace(System.IO.Path.GetExtension(layerPath), string.Empty)); if (!oGeoDataset.Equals(null)) { oLayer = new MapLayerClass(); oLayer.GeoDataset = oGeoDataset; oConn.Disconnect(); } } return oLayer; }
/// <summary> /// /// </summary> /// <param name="layerPath"></param> /// <returns></returns> public MapLayer GetLayer(string layerPath) { if (!System.IO.File.Exists(layerPath)) { return(null); } GeoDataset oGeoDataset = null; DataConnection oConn = new DataConnectionClass(); MapLayer oLayer = null; oConn.Database = System.IO.Path.GetDirectoryName(layerPath); if (oConn.Connect()) { oGeoDataset = oConn.FindGeoDataset(System.IO.Path.GetFileName(layerPath).Replace(System.IO.Path.GetExtension(layerPath), string.Empty)); if (!oGeoDataset.Equals(null)) { oLayer = new MapLayerClass(); oLayer.GeoDataset = oGeoDataset; oConn.Disconnect(); } } return(oLayer); }
/// <summary> /// When the user clicks this button validate the data and write it to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { // Reset ResetError(); // Test data before writing to the DB if (ValidateData() && message == "ADD") // If adding a user { // Fill entity newUser.FirstName = txtFirstName.Text; newUser.LastName = txtLastName.Text; newUser.Level = new Role() { Role_id = returnRoleId() }; newUser.Username = txtUsername.Text; newUser.PassWord = txtPassword.Text; newUser.Person_Id = txtBoxPersonId.Text; // Write the data to the DB DataConnectionClass.UserConn.Write1User(newUser); DataConnectionClass.SavePersonId(); DataConnectionClass.AuditLogConnClass.AddRecordToAudit("added a new user: "******"EDIT") // If editing the user { // Create usedr entity User newUser = new User(); // Fill entity newUser.Id = userToBeEdited.Id; newUser.Notes = userToBeEdited.Notes; newUser.FirstName = txtFirstName.Text; newUser.LastName = txtLastName.Text; newUser.Level = new Role() { Role_id = returnRoleId() }; newUser.Username = txtUsername.Text; newUser.PassWord = txtPassword.Text; newUser.Person_Id = txtBoxPersonId.Text; // Write the data to the DB DataConnectionClass.UserConn.Update1User(newUser); DataConnectionClass.AuditLogConnClass.AddRecordToAudit("edited user: "******"ADD" && message != "EDIT") // If the message is empty { MessageBox.Show("It seems there was an error with the form.\r\n\r\nTry Again!", "Uh-oh", MessageBoxButtons.OK, MessageBoxIcon.Stop); this.Close(); } else // If there is bad data { MessageBox.Show("All fields must have correct data!", "Uh-oh", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
/// <summary> /// Grab the data from the form, check for errors, create a package entity, and add it to the database /// </summary> public void AddPackageToDB() { // Create Package FillPackage(); // Write Package DataConnectionClass.PackageConnClass.AddPackage(newPackage); //do this ONLY on add DataConnectionClass.SavePersonId(); //Connections.DataConnections.DataConnectionClass.DataLists.Packages.Add(newPackage); DataConnectionClass.PackageConnClass.GetPackageList(this.ParentForm); }
/// <summary> /// Create part of the use id from the fist name field /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtFirstName_Leave(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(txtFirstName.Text) && message != "EDIT") { if (txtFirstName.Text.Length < 4) { DataConnectionClass.CreatePersonId(txtFirstName.Text.ToLower().Substring(0, txtFirstName.Text.Length)); txtBoxPersonId.Text = DataConnectionClass.PersonIdGenerated; } else { DataConnectionClass.CreatePersonId(txtFirstName.Text.ToLower().Substring(0, 4)); txtBoxPersonId.Text = DataConnectionClass.PersonIdGenerated; } } }
/// <summary> /// This icon will indicate the current user who is logged in and thier permission level. /// -Upon click it will sign the user out and load the login form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pictureBox1_Click(object sender, EventArgs e) { DataConnectionClass.LogUserOut(); GoToLogIn(); }
/// <summary> /// Check the databse and load the data /// </summary> public LogIn() { InitializeComponent(); DataConnectionClass.GetDatabaseData(); DataConnectionClass.TestConn.Checktables(); }
public BaseDAL() { myConnection = new DataConnectionClass(); }
private void cmboBuilding_SelectionChangeCommitted(object sender, EventArgs e) { if (message != "EDIT") { cmboBuilding.Text = cmboBuilding.SelectedItem.ToString(); if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (txtPO.Text.Length < 4) { WorkingPID = txtPO.Text.ToLower().Substring(0, txtPO.Text.Length); } else { WorkingPID = txtPO.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboCarrier.Text)) { if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (cmboCarrier.Text.Length < 4) { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, 4); } } else { if (cmboCarrier.Text.Length < 4) { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, 4); } } } if (!String.IsNullOrWhiteSpace(cmboVendor.Text)) { if (cmboVendor.Text.Length < 4) { WorkingPID += cmboVendor.Text.ToLower().Substring(0, cmboVendor.Text.Length); } else { WorkingPID += cmboVendor.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboRecipiant.Text)) { if (cmboRecipiant.Text.Length < 4) { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, cmboRecipiant.Text.Length); } else { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboBuilding.Text)) { if (cmboBuilding.Text.Length < 4) { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, cmboBuilding.Text.Length); } else { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, 4); } } DataConnectionClass.CreatePersonId(WorkingPID); txtRoleId.Text = DataConnectionClass.PersonIdGenerated; } newPackage.DelivBuildingShortName = cmboBuilding.Text; }
private void cmboRecipiant_SelectionChangeCommitted(object sender, EventArgs e) { if (message != "EDIT") { cmboRecipiant.Text = cmboRecipiant.SelectedItem.ToString(); if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (txtPO.Text.Length < 4) { WorkingPID = txtPO.Text.ToLower().Substring(0, txtPO.Text.Length); } else { WorkingPID = txtPO.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboCarrier.Text)) { if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (cmboCarrier.Text.Length < 4) { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, 4); } } else { if (cmboCarrier.Text.Length < 4) { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, 4); } } } if (!String.IsNullOrWhiteSpace(cmboVendor.Text)) { if (cmboVendor.Text.Length < 4) { WorkingPID += cmboVendor.Text.ToLower().Substring(0, cmboVendor.Text.Length); } else { WorkingPID += cmboVendor.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboRecipiant.Text)) { if (cmboRecipiant.Text.Length < 4) { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, cmboRecipiant.Text.Length); } else { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboBuilding.Text)) { if (cmboBuilding.Text.Length < 4) { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, cmboBuilding.Text.Length); } else { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, 4); } } DataConnectionClass.CreatePersonId(WorkingPID); txtRoleId.Text = DataConnectionClass.PersonIdGenerated; fac = DataConnectionClass.DataLists.FacultyList.FirstOrDefault(i => i.ToString() == cmboRecipiant.Text); BuildingClass b = DataConnectionClass.DataLists.BuildingNames.FirstOrDefault(i => i.BuildingId == fac.Building_Id); cmboBuilding.SelectedItem = b.BuildingShortName; cmboBuilding_SelectionChangeCommitted(this, e); lblroom.Text = fac.RoomNumber; newPackage.DelivBuildingShortName = cmboBuilding.Text + " " + fac.RoomNumber; } else { fac = DataConnectionClass.DataLists.FacultyList.FirstOrDefault(i => i.ToString() == cmboRecipiant.Text); BuildingClass b = DataConnectionClass.DataLists.BuildingNames.FirstOrDefault(i => i.BuildingId == fac.Building_Id); cmboBuilding.SelectedItem = b.BuildingShortName; cmboBuilding_SelectionChangeCommitted(this, e); lblroom.Text = fac.RoomNumber; newPackage.DelivBuildingShortName = cmboBuilding.Text + " " + fac.RoomNumber; } }
private void txtPO_Leave(object sender, EventArgs e) { if (message != "EDIT") { if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (txtPO.Text.Length < 4) { WorkingPID = txtPO.Text.ToLower().Substring(0, txtPO.Text.Length); } else { WorkingPID = txtPO.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboCarrier.Text)) { if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (cmboCarrier.Text.Length < 4) { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, 4); } } else { if (cmboCarrier.Text.Length < 4) { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, 4); } } } if (!String.IsNullOrWhiteSpace(cmboVendor.Text)) { if (cmboVendor.Text.Length < 4) { WorkingPID += cmboVendor.Text.ToLower().Substring(0, cmboVendor.Text.Length); } else { WorkingPID += cmboVendor.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboRecipiant.Text)) { if (cmboRecipiant.Text.Length < 4) { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, cmboRecipiant.Text.Length); } else { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboBuilding.Text)) { if (cmboBuilding.Text.Length < 4) { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, cmboBuilding.Text.Length); } else { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, 4); } } DataConnectionClass.CreatePersonId(WorkingPID); txtRoleId.Text = DataConnectionClass.PersonIdGenerated; } }
private void cmboRecipiant_SelectionChangeCommitted(object sender, EventArgs e) { if (message != "EDIT" || (message == "ADD" && newPackage.Notes.Count == 0)) { cmboRecipiant.Text = cmboRecipiant.SelectedItem.ToString(); if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (txtPO.Text.Length < 4) { WorkingPID = txtPO.Text.ToLower().Substring(0, txtPO.Text.Length); } else { WorkingPID = txtPO.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboCarrier.Text)) { if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (cmboCarrier.Text.Length < 4) { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, 4); } } else { if (cmboCarrier.Text.Length < 4) { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, 4); } } } if (!String.IsNullOrWhiteSpace(cmboVendor.Text)) { if (cmboVendor.Text.Length < 4) { WorkingPID += cmboVendor.Text.ToLower().Substring(0, cmboVendor.Text.Length); } else { WorkingPID += cmboVendor.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboRecipiant.Text)) { if (cmboRecipiant.Text.Length < 4) { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, cmboRecipiant.Text.Length); } else { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboBuilding.Text)) { if (cmboBuilding.Text.Length < 4) { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, cmboBuilding.Text.Length); } else { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, 4); } } DataConnectionClass.CreatePersonId(WorkingPID); txtRoleId.Text = DataConnectionClass.PersonIdGenerated; fac = DataConnectionClass.DataLists.FacultyList.FirstOrDefault(i => i.ToString() == cmboRecipiant.Text); BuildingClass b = DataConnectionClass.DataLists.BuildingNames.FirstOrDefault(i => i.BuildingId == fac.Building_Id); cmboBuilding.SelectedItem = b.BuildingShortName; cmboBuilding_SelectionChangeCommitted(this, e); lblroom.Text = fac.RoomNumber; newPackage.DelivBuildingShortName = cmboBuilding.Text + " " + fac.RoomNumber; } else { string compairer = cmboRecipiant.Text; foreach (Faculty f in DataConnectionClass.DataLists.FacultyList) { string fname = f.ToString(); if (fname == compairer) { fac = f; break; } } if (fac == null) { MessageBox.Show("Null Faculty object. Aborting.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //break point BuildingClass b = new BuildingClass(); foreach (BuildingClass build in DataConnectionClass.DataLists.BuildingNames) { if (build.BuildingId == fac.Building_Id) { b = build; break; } } cmboBuilding.SelectedItem = b.BuildingShortName; cmboBuilding_SelectionChangeCommitted(this, e); lblroom.Text = fac.RoomNumber; newPackage.DelivBuildingShortName = cmboBuilding.Text + " " + fac.RoomNumber; } isSlectedItem[1] = true; selecteditem = cmboRecipiant.SelectedItem; btnReceive.Enabled = IsRequiredItemsSelected(); }
private void cmboVendor_SelectionChangeCommitted(object sender, EventArgs e) { if (message != "EDIT" || (message == "ADD" && newPackage.Notes.Count == 0)) { cmboVendor.Text = cmboVendor.SelectedItem.ToString(); if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (txtPO.Text.Length < 4) { WorkingPID = txtPO.Text.ToLower().Substring(0, txtPO.Text.Length); } else { WorkingPID = txtPO.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboCarrier.Text)) { if (!String.IsNullOrWhiteSpace(txtPO.Text)) { if (cmboCarrier.Text.Length < 4) { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID += cmboCarrier.Text.ToLower().Substring(0, 4); } } else { if (cmboCarrier.Text.Length < 4) { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, cmboCarrier.Text.Length); } else { WorkingPID = cmboCarrier.Text.ToLower().Substring(0, 4); } } } if (!String.IsNullOrWhiteSpace(cmboVendor.Text)) { if (cmboVendor.Text.Length < 4) { WorkingPID += cmboVendor.Text.ToLower().Substring(0, cmboVendor.Text.Length); } else { WorkingPID += cmboVendor.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboRecipiant.Text)) { if (cmboRecipiant.Text.Length < 4) { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, cmboRecipiant.Text.Length); } else { WorkingPID += cmboRecipiant.Text.ToLower().Substring(0, 4); } } if (!String.IsNullOrWhiteSpace(cmboBuilding.Text)) { if (cmboBuilding.Text.Length < 4) { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, cmboBuilding.Text.Length); } else { WorkingPID += cmboBuilding.Text.ToLower().Substring(0, 4); } } DataConnectionClass.CreatePersonId(WorkingPID); txtRoleId.Text = DataConnectionClass.PersonIdGenerated; } isSlectedItem[0] = true; selecteditem = cmboVendor.SelectedItem; btnReceive.Enabled = IsRequiredItemsSelected(); }
public UserDAL() { myConnection = new DataConnectionClass(); }