private void button1_Click(object sender, EventArgs e) { if (validationProvider1.IsValid) { Profs pf = new Profs(); pf.ProfName = profNameTextBox.Text; pf.NoOfCourses = Convert.ToInt16(numericUpDown1.Text); pf.UnassignedProf = checkBox1.Checked; errorLabel.Visible = false; if (EditingType == 0) { pf.AddProf(); } else { pf.UpdateProf(PID); } button1.DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } else { errorLabel.Text = "There are some errors"; errorLabel.Visible = true; } }
public static Profs getProfsPed(int _ped) { Profs profs = new Profs(); using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConn"].ToString())) { SqlCommand cmm = cnn.CreateCommand(); cmm.CommandText = "SELECT Profissionais_Pedido.Cod_Profissional, Profissionais.Nome " + "FROM Profissionais INNER JOIN Profissionais_Pedido ON " + "Profissionais.Cod_Profissional = Profissionais_Pedido.Cod_Profissional " + "WHERE (Profissionais_Pedido.Num_Pedido = @numped) order by Profissionais.Nome "; cmm.Parameters.Add("@numped", SqlDbType.Int).Value = _ped; try { cnn.Open(); SqlDataReader dr = cmm.ExecuteReader(); Prof pf; while (dr.Read()) { pf = new Prof(); pf.Cod = dr.GetInt32(0); pf.Nome = dr.GetString(1); profs.Items.Add(pf.Cod, pf); } } catch { } } return(profs); }
private void refreshProfs_Click() { try { profBS = new BindingSource(Profs.GetAll(), ""); ProfsGridView.DataSource = profBS; ProfsNavigator.BindingSource = profBS; comboBox1.DataSource = profBS; if (profBS.Count > 0) { comboBox1.Enabled = true; var tbs = new BindingSource(Profs.GetAll(), "") { new Profs("All Professors") }; comboBox1.DataSource = tbs; comboBox1.DisplayMember = "ProfName"; comboBox1.SelectedIndex = comboBox1.Items.Count - 1; } else { comboBox1.Enabled = false; } } catch (Exception) { MessageBox.Show("Could not connect to SQL Server" + "\n" + "Please make sure SQL server express is installed"); err = 1; } }
public static byte[] ProfPacket(uint ProfID, Profs.Prof Prof) { Writer PWR = new Writer(16); PWR.Fill((ushort)16, 0); PWR.Fill((ushort)1025, 2); PWR.Fill(ProfID, 4); PWR.Fill((uint)Prof.Level, 8); PWR.Fill(Prof.Experience, 12); return PWR.Bytes; }
public AddCourse() { InitializeComponent(); allprofs = new ArrayList(); allprofs.Add(new Profs("No Prof Assigned")); foreach (Profs pf in Profs.GetAll()) { allprofs.Add(pf); } comboBox1.DataSource = allprofs; comboBox1.DisplayMember = "ProfName"; this.ValidateChildren(); }
public static Profs Get_client_ID(int id) { string requete = String.Format("select * from prof where id={0};", id); OleDbDataReader rd = utils.lire(requete); Profs c = new Profs(); while (rd.Read()) { c.id = rd.GetInt32(0); c.Nom = rd.GetString(1); c.Prenom = rd.GetString(2); c.adresse = rd.GetString(3); c.mail = rd.GetString(4); } utils.Disconnect(); return(c); }
private void button3_Click(object sender, EventArgs e) { try { Profs pro = ProfDAO.Get_client_ID(int.Parse(tbID_p.Text)); tbnom.Text = pro.Nom; tbprenom.Text = pro.Prenom; tbadresse.Text = pro.adresse; tbmail.Text = pro.mail; List <Profs> L = new List <Profs>(); L.Add(pro); grid_clients.DataSource = L; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public AddCourse(string title, int CID, string CourseName, string TimeSlot, string DOW, int?ProfID, int type) : this() { Text = title; courseNameTextBox.Text = CourseName; timeSlotTextBox.Text = TimeSlot; DOWTextBox.Text = DOW; this.CID = CID; for (int i = 1; i < allprofs.Count; i++) // start with 1; { Profs pf = (Profs)allprofs[i]; if (pf.ProfID == ProfID) { comboBox1.SelectedIndex = i; break; } } EditingType = type == 0 ? 0 : 1; ValidateChildren(); }
private void toolStripButton3_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show(this, "Do you really want to delete this professor?", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { if (Profs.DeleteProf(((Profs)profBS.Current).ProfID)) { profBS.RemoveCurrent(); int position = profBS.Position; refreshProfs_Click(); profBS.Position = position; } else { MessageBox.Show("Cannot delete this professor...some courses are related to this professor!!"); } } }
private void Update() { var OptionsBuilder = new DbContextOptionsBuilder <DataBaseContext>(); OptionsBuilder.UseSqlite("Data Source=app.db"); List <Professor> ProfsL; using (var DB = new DataBaseContext(OptionsBuilder.Options)) { ProfsL = DB.Professors .AsNoTracking() .Include(x => x.Comments) .Include(x => x.ProfFacs) .ThenInclude(y => y.Faculty) .Where(x => x.Approved) .ToList(); } lock (_lock) { Profs.Clear(); ProfessorCacheViewModel.MaxComment = int.MinValue; foreach (var item in ProfsL) { Profs.Add(new ProfessorCacheViewModel { ID = item.ID, FullName = item.FullName, Score = item.Score, FacIDs = item.ProfFacs.Select(x => x.Faculty.AliasName).ToList(), ImageLink = item.ImageLink, CommentCount = item.CommentCount }); if (item.CommentCount > ProfessorCacheViewModel.MaxComment) { ProfessorCacheViewModel.MaxComment = item.CommentCount; } } LastUpdate = DateTime.Now; } }
public static List <Profs> Get_clients() { string requete = String.Format("select * from prof;"); OleDbDataReader rd = utils.lire(requete); List <Profs> L = new List <Profs>(); Profs c; while (rd.Read()) { c = new Profs { id = rd.GetInt32(0), Nom = rd.GetString(1), Prenom = rd.GetString(2), adresse = rd.GetString(3), mail = rd.GetString(4) }; L.Add(c); } utils.Disconnect(); return(L); }
public static SQLInsert gravaFechamentoPedido(int _numped, ExamesRealzs _exms, Profs _profs, MateriaisUtils _mats, int _status) { SQLInsert sqi = new SQLInsert(); using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConn"].ToString())) { SqlCommand cmm = cnn.CreateCommand(); cnn.Open(); SqlTransaction st = cnn.BeginTransaction(); cmm.Transaction = st; try { cmm.CommandText = "select cod_status from pedidos where num_pedido = @numped"; cmm.Parameters.Add("@numped", SqlDbType.Int).Value = _numped; int status = (int)cmm.ExecuteScalar(); int ent_log = 4; if (status != 3) { cmm.CommandText = "update pedidos set cod_status = 3 where num_pedido = @numped"; cmm.ExecuteNonQuery(); ent_log = 3; } cmm.CommandText = "DELETE FROM Exames_Pedido WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); if (_exms.Items.Count > 0) { cmm.CommandText = "INSERT INTO Exames_Pedido (Cod_Exame,Num_Pedido) VALUES (@exm,@numped)"; cmm.Parameters.Add("@exm", SqlDbType.Int); foreach (ExameRealz exm in _exms.Items.Values) { cmm.Parameters["@exm"].Value = exm.Cod_exame; cmm.ExecuteNonQuery(); } } cmm.CommandText = "DELETE FROM Profissionais_Pedido WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); if (_profs.Items.Count > 0) { cmm.CommandText = "INSERT INTO Profissionais_Pedido (Cod_Profissional, Num_Pedido) VALUES (@prof,@numped)"; cmm.Parameters.Add("@prof", SqlDbType.Int); foreach (Prof pf in _profs.Items.Values) { cmm.Parameters["@prof"].Value = pf.Cod; cmm.ExecuteNonQuery(); } } cmm.CommandText = "DELETE FROM Materiais_Pedido WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); if (_mats.Items.Count > 0) { cmm.CommandText = "INSERT INTO Materiais_Pedido (Cod_Material, Num_Pedido,Qtd) VALUES (@mat,@numped,@qtd)"; cmm.Parameters.Add("@mat", SqlDbType.Int); cmm.Parameters.Add("@qtd", SqlDbType.Int); foreach (MaterialUtil mt in _mats.Items.Values) { cmm.Parameters["@mat"].Value = mt.Cod; cmm.Parameters["@qtd"].Value = mt.Qtd; cmm.ExecuteNonQuery(); } } cmm.CommandText = "INSERT INTO Log_Pedido ([Num_Pedido],[TimeStamp],[Usuario],[Cod_Ent_Log]) " + "VALUES (@numped,getdate(),@usu,@entlog)"; cmm.Parameters.Add("@entlog", SqlDbType.Int).Value = ent_log; cmm.Parameters.Add("@usu", SqlDbType.UniqueIdentifier).Value = (Guid)Membership.GetUser().ProviderUserKey; cmm.ExecuteNonQuery(); st.Commit(); sqi.Success = true; } catch (Exception ex) { sqi.Success = false; sqi.Erro = ex.Message; try { st.Rollback(); } catch (Exception ex1) { sqi.Erro += ex1.Message; } } } return(sqi); }