コード例 #1
0
 private void Modifbtn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int id = int.Parse(txtid.Text);
         if (pathImagePortada != pathup)
         {
         }
         teacher     = new Model.Teacher(id, txtnameMod.Text, txtlastnameMod.Text, txtsecondlastnameMod.Text, txtAddressMod.Text, txtPhoneMod.Text, txtemailMod.Text, ubicationPoint.Latitude, ubicationPoint.Longitude, idTown, pathup, pathImagePortada);
         teacherimpl = new TeacherImpl();
         int res = teacherimpl.Update(teacher);
         if (res > 0)
         {
             MessageBox.Show("Teacher Modifed successfully!!!");
             LoadDataGrid();
             ocultar();
         }
         else
         {
             MessageBox.Show("Something happened \nCommunicate with the Suport department \[email protected]");
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #2
0
ファイル: TeacherDAL.cs プロジェクト: smilelhh/-web-
        public object getByTeacherId(string teacherId)
        {
            Teacher teacher = null;

            string selectSql = "SELECT * FROM t_teacher WHERE teacherId=@teacherId";

            SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@teacherId", teacherId) };

            DataSet ds = SQLServerDBUtil.query(selectSql, sqlParas);

            if (ds.Tables[0].Rows.Count != 0)
            {
                teacher = new Teacher();
                teacher.Id = ds.Tables[0].Rows[0][0].ToString();
                teacher.TeacherId = ds.Tables[0].Rows[0][1].ToString();
                teacher.Name = ds.Tables[0].Rows[0][2].ToString();
                teacher.Gender = ds.Tables[0].Rows[0][3].ToString();
                teacher.Birth = ds.Tables[0].Rows[0][4].ToString();
                teacher.Title = ds.Tables[0].Rows[0][5].ToString();
                teacher.Phone = ds.Tables[0].Rows[0][6].ToString();
                teacher.Email = ds.Tables[0].Rows[0][7].ToString();
                teacher.UserID = ds.Tables[0].Rows[0][8].ToString();
            }

            return teacher;
        }
コード例 #3
0
        public Teacher TeaLogin(string userName, string userPwd)
        {
            string sql = @"SELECT tea_id,tea_password FROM tea_inform WHERE tea_id=@UserName AND tea_password=@Password";

            SqlParameter[] pms =
            {
                new SqlParameter(@"UserName", userName),
                new SqlParameter(@"Password", userPwd)
            };
            SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.Text, pms);

            Model.Teacher user = null;

            //读取具体的数据
            while (reader.Read())
            {
                if (user == null)
                {
                    user = new Model.Teacher();
                }
                //读取查询到的数据
                user.Tea_Id       = reader.GetString(0);
                user.Tea_Password = reader.GetString(1);
            }
            return(user);
        }
コード例 #4
0
        private void InsertNow_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UsuarioAniadir();
                //names, lastName, secondLastName, address, phone, birthDate,gender,startDate,email
                if (txtname.Text != "" && txtlastname.Text != "" && txtAddress.Text != "" && txtPhone.Text != "" && txtBirth.Text != "" && txtGender.Text != "" && txtstartDate.Text != "" && txtemail.Text != "")
                {
                    string contraniafin = contrasenia();
                    string second;
                    if (txtsecondlastname.Text == null)
                    {
                        second = "";
                    }
                    else
                    {
                        second = txtsecondlastname.Text;
                    }
                    UsuarioAniadir();
                    teacher      = new Model.Teacher(txtname.Text, txtlastname.Text, second, txtAddress.Text, txtPhone.Text, txtBirth.SelectedDate.Value, txtGender.Text, txtstartDate.SelectedDate.Value, txtemail.Text, ubicationPoint.Latitude, ubicationPoint.Longitude, idTown, pathImagePortada);
                    usuarioclass = new User(usuario, contraniafin, "P", 0);

                    teacherimpl.InsertTransaction(usuarioclass, teacher);


                    image = new BitmapImage();
                    image.BeginInit();
                    image.CacheOption = BitmapCacheOption.OnLoad;
                    image.UriSource   = new Uri(DBImplementation.pathImages + 0 + ".png");
                    image.EndInit();
                    imagesector.Source = image;



                    pathImagePortada = null;
                    SendEmail(txtemail.Text, usuario.ToUpper(), contraniafin);
                    LoadDataGrid();
                    ocultar();
                }
                else
                {
                    MessageBox.Show("Don't leave data empty");
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #5
0
        private void DgvDatos_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (dgvDatos.Items.Count > 0 && dgvDatos.SelectedItem != null)
            {
                try
                {
                    modif();
                    DataRowView dataRow = (DataRowView)dgvDatos.SelectedItem;
                    int         id      = int.Parse(dataRow.Row.ItemArray[0].ToString());
                    teacherimpl               = new TeacherImpl();
                    teacher                   = teacherimpl.Get(id);
                    txtid.Text                = teacher.PersonId.ToString();
                    txtnameMod.Text           = teacher.Names;
                    txtnameDel.Text           = teacher.Names;
                    txtlastnameMod.Text       = teacher.LastName;
                    txtlastnameDel.Text       = teacher.LastName;
                    txtsecondlastnameMod.Text = teacher.SecondLastName;
                    txtemailMod.Text          = teacher.Email;
                    txtPhoneMod.Text          = teacher.Phone;
                    txtAddressMod.Text        = teacher.Address;

                    image = new BitmapImage();
                    image.BeginInit();
                    image.CacheOption = BitmapCacheOption.OnLoad;
                    image.UriSource   = new Uri(DBImplementation.pathImages + teacher.Photo + ".png");
                    image.EndInit();
                    imagesector.Source = image;


                    pathImagePortada = DBImplementation.pathImages + teacher.Photo + ".png";
                    pathup           = pathImagePortada;
                    Location ubi = new Location(teacher.Latitude, teacher.Longitude);
                    MyMap.Center   = ubi;
                    ubicationPoint = ubi;
                    Pushpin point = new Pushpin();
                    point.Location = ubi;
                    MyMap.Children.Clear();
                    MyMap.Children.Add(point);
                    idmodi = teacher.TownId;
                    llamarmuni(teacher.TownId);
                    Modif.IsEnabled  = true;
                    Delete.IsEnabled = true;
                }
                catch (Exception ex)
                {
                }
            }
        }
コード例 #6
0
        private void Delbtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int id = int.Parse(txtid.Text);
                teacher     = new Model.Teacher(id, txtnameDel.Text, txtlastnameDel.Text);
                teacherimpl = new TeacherImpl();
                teacherimpl.Delete(teacher);

                LoadDataGrid();
                ocultar();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something happened \nCommunicate with the Suport department \[email protected]");
            }
        }
コード例 #7
0
 private void Disabledbtn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (enable == true)
         {
             int id = int.Parse(txtid.Text);
             teacher     = new Model.Teacher(id, "", "");
             teacherimpl = new TeacherImpl();
             int res = teacherimpl.Disabled(teacher);
             if (res > 0)
             {
                 MessageBox.Show("Teacher Disable successfully!!!");
                 LoadDataGrid();
                 ocultar();
             }
             else
             {
                 MessageBox.Show("Something happened \nCommunicate with the Suport department \[email protected]");
             }
         }
         else
         {
             int id = int.Parse(txtid.Text);
             teacher     = new Model.Teacher(id, "", "");
             teacherimpl = new TeacherImpl();
             int res = teacherimpl.Enabled(teacher);
             if (res > 0)
             {
                 MessageBox.Show("Teacher Enable successfully!!!");
                 LoadDataGridDis();
                 ocultar();
             }
             else
             {
                 MessageBox.Show("Something happened \nCommunicate with the Suport department \[email protected]");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #8
0
        private void DgvDatos_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (dgvDatos.Items.Count > 0 && dgvDatos.SelectedItem != null)
            {
                try
                {
                    Disabledbtn.IsEnabled = true;
                    subjects.IsEnabled    = true;
                    DataRowView dataRow = (DataRowView)dgvDatos.SelectedItem;
                    int         id      = int.Parse(dataRow.Row.ItemArray[0].ToString());

                    teacherimpl         = new TeacherImpl();
                    teacher             = teacherimpl.Get(id);
                    txtid.Text          = teacher.PersonId.ToString();
                    namenabled.Content  = teacher.Names;
                    lastenabled.Content = teacher.LastName;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }