public DataBaseControl(Person person)
 {
     InitializeComponent();
     lbl_name.Text = person.User.Name;
     lbl_phone.Text = person.User.PhoneNo;
     lbl_address.Text = person.User.Address;
     int count = person.Images.Count;
     cameraImages = new List<Image>();
     imagePaths = new List<string>();
     p = person;
     for (int i = 0; i < count;i++ )
     {
         imagePaths.Add(person.Images[i].ImagePath);
     }
     
     GeniratePicBox(imagePaths);
 }
Пример #2
0
        public SpendDetail(DMode d, Button btn)
        {
            mode = d;
            InitializeComponent();
            SQLite = new SQLite();
            #region 변수 초기화

            budgetPray = new Pray();
            budgetMissionWork = new MissionWork();
            budgetEdu = new Education();
            budgetPerson = new Person();
            budgetService = new Service();
            budgetManage = new Manage();
            budgetLoan = new Loan();

            curPray = new Pray();
            curMissionWork = new MissionWork();
            curEdu = new Education();
            curPerson = new Person();
            curService = new Service();
            curManage = new Manage();
            curLoan = new Loan();

            #endregion

            printBtn = btn;

            // 표 설정
            setView();

            Paint += SpendDetail_Paint;
        }
Пример #3
0
        //====================================================================================================================

        /// <summary>
        /// Deletes the person.
        /// </summary>
        /// <param name="ID">The ID.</param>
        public void DeletePerson(int ID)
        {
            Person p;
            int id = -1;

            foreach (Person per in Persons)
            {
                id++;

                if (per.User.UserID == ID)
                {
                    break;
                }
            }

            p = new Person(Persons[id].User, Persons[id].Images);
            Persons.Remove(p);

            try
            {
                con.Open();
                string deleteImage = @"DELETE FROM Users WHERE UserID = @ID";
                SqlCeCommand cmd = new SqlCeCommand(deleteImage, con);
                cmd.Parameters.Add(new SqlCeParameter("@ID", p.User.UserID));
                cmd.ExecuteNonQuery();

                foreach (Images i in p.Images)
                {
                    DeleteImage(p, i.ImageID, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw new Exception(ex.Message, ex);

            }
            finally
            {
                con.Close();
            }
        }
Пример #4
0
        //====================================================================================================================

        /// <summary>
        /// deletes one image
        /// </summary>
        /// <param name="p">the specified person you will delete his image</param>
        /// <param name="ImageID">the image ID you want to delete</param>
        /// <param name="flag">True if u remove an image</param>
        public void DeleteImage(Person p, int ImageID, bool flag)
        {
            int index = 0;
            Images imag = new Images(-1, "", -1);
            try
            {
                if (flag)
                    con.Open();

                string deleteImage = @"DELETE FROM Images WHERE ImageID = @ID";
                SqlCeCommand cmd = new SqlCeCommand(deleteImage, con);
                cmd.Parameters.Add(new SqlCeParameter("@ID", ImageID));
                cmd.ExecuteNonQuery();

                if (flag)
                {
                    index = persons.IndexOf(p);
                    foreach (Images image in persons[index].Images)
                    {
                        if (image.ImageID == ImageID)
                        {
                            imag = image;
                            persons[index].Images.Remove(image);
                            break;
                        }
                    }
                }

                if (!flag)
                {
                    index = 0;
                    foreach (Images image in p.Images)
                    {
                        if (image.ImageID == ImageID)
                        {
                            break;
                        }
                        index++;
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

               // throw new Exception(ex.Message, ex);

            }
            finally
            {
                if (flag)
                {
                    con.Close();
                    //File.Delete(imag.ImagePath);
                }
                else
                {
                    //File.Delete(p.Images[index].ImagePath);
                }
            }
        }
Пример #5
0
        //====================================================================================================================

        /// <summary>
        /// Updates the user info.
        /// </summary>
        /// <param name="oldPID">The old PID.</param>
        /// <param name="newPerson">The new person.</param>
        public void UpdateUserInfo(int oldPID, Users newPerson)
        {
            Person oldP;
            int id = -1;

            foreach (Person per in Persons)
            {
                id++;

                if (per.User.UserID == oldPID)
                {
                    break;
                }
            }

            oldP = new Person(Persons[id].User, Persons[id].Images);

            persons[id].User = newPerson;

            try
            {
                con.Open();
                string Update = @"update Users Set UserName = @name, UserPhone = @phone, UserAddress = @address  WHERE UserID = @ID";
                SqlCeCommand cmd = new SqlCeCommand(Update, con);
                cmd.Parameters.Add(new SqlCeParameter("@ID", oldPID));
                cmd.Parameters.Add(new SqlCeParameter("@name", newPerson.Name));
                cmd.Parameters.Add(new SqlCeParameter("@phone", newPerson.PhoneNo));
                cmd.Parameters.Add(new SqlCeParameter("@address", newPerson.Address));
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
               // throw new Exception(ex.Message, ex);
            }
            finally
            {
                con.Close();
            }
        }
Пример #6
0
        //====================================================================================================================

        /// <summary>
        /// Inserts the specified person.
        /// </summary>
        /// <param name="person">The person.</param>
        public void Insert(Person person)
        {
            try
            {
                con.Open();
                string insertUser = @"Insert Into Users(UserName, UserPhone, UserAddress) Values(@name, @phone, @address)";
                SqlCeCommand cmd = new SqlCeCommand(insertUser, con);
                cmd.Parameters.Add(new SqlCeParameter("@name", person.User.Name));
                cmd.Parameters.Add(new SqlCeParameter("@phone", person.User.PhoneNo));
                cmd.Parameters.Add(new SqlCeParameter("@address", person.User.Address));

                cmd.ExecuteNonQuery();
                int id = -1;

                cmd = new SqlCeCommand("select UserID  From Users where UserID = @@IDENTITY", con);
                SqlCeDataReader rdr = cmd.ExecuteReader();
                rdr.Read();
                if (rdr[0] != DBNull.Value)
                {
                    id = (int)rdr[0];


                    person.User.UserID = id;
                    Persons.Add(person);
                    int count = person.Images.Count;
                    for (int i = 0; i < count; i++)
                    {
                        person.Images[i].UserID = id;
                        InsertImage(id, person.Images[i].ImagePath, false);
                        person.Images.Remove(person.Images.Last());
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw new Exception("Cannot Connect to the database", ex);
            }
            finally
            {
                con.Close();
            }
        }