public void ReadInfo_Click(object sender, EventArgs e)
        {
            Form A = null;

            if (sender.Equals(ReadInfo) || sender.Equals(预览XToolStripMenuItem))
            {
                A = new ReadInfoForm();
            }
            else if (sender.Equals(ManageInfo) || sender.Equals(管理BToolStripMenuItem))
            {
                A = new ManageInfoForm();
            }
            else if (sender.Equals(SearchInfo) || sender.Equals(搜索CToolStripMenuItem))
            {
                A = new SearchInfoForm();
            }
            else if (sender.Equals(Explanation) || sender.Equals(说明DToolStripMenuItem))
            {
                A = new ExplanationForm();
            }
            else if (sender.Equals(Anthor) || sender.Equals(作者EToolStripMenuItem))
            {
                A = new Anthor();
            }
            this.ForMF.Dispose();
            this.Hide();
            A.Show();
        }
        private void 作者EToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form A = null;

            if (sender.Equals(预览XToolStripMenuItem))
            {
                A = new MainForm();
            }
            else if (sender.Equals(管理BToolStripMenuItem))
            {
                A = new ReadInfoForm();
            }
            else if (sender.Equals(搜索CToolStripMenuItem))
            {
                A = new ManageInfoForm();
            }
            else if (sender.Equals(说明DToolStripMenuItem))
            {
                A = new ExplanationForm();
            }
            else if (sender.Equals(作者EToolStripMenuItem))
            {
                A = new Anthor();
            }
            this.ForMF.Dispose();
            this.Hide();
            A.Show();
        }
Пример #3
0
        static public void DeleteImage(int InfoIndex, int ImageIndex, ReadInfoForm This)
        {
            DialogResult D = MessageBox.Show("您确定要删除当前照片吗?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (D == DialogResult.OK)
            {
                Start();
                int Max = ImageIndexMax(InfoIndex, ImageIndex);

                while (ImageIndex <= Max)
                {
                    if (ImageIndex + 1 >= 10)
                    {
                        Set.Tables[0].Rows[InfoIndex][ImageIndex] = null;
                        break;
                    }
                    else
                    {
                        Set.Tables[0].Rows[InfoIndex][ImageIndex] =
                            Set.Tables[0].Rows[InfoIndex][ImageIndex + 1];
                    }
                    ImageIndex++;
                }
                End();

                Heart.Read(InfoIndex, ImageIndex = 5, This);
                MessageBox.Show("删除成功", "Delete", MessageBoxButtons.OK);
            }
        }
Пример #4
0
 static public void Read(int InfoIndex, int ImageIndex, ReadInfoForm ReadInfo)
 {
     Start();
     if (ImageIndex > 9)
     {
         ImageIndex = 5;
     }
     if (ImageIndex == 5)
     {
         ReadInfo.textBox1.Text = Set.Tables[0].Rows[InfoIndex][0].ToString();
         ReadInfo.textBox2.Text = Set.Tables[0].Rows[InfoIndex][1].ToString();
         ReadInfo.textBox3.Text = Set.Tables[0].Rows[InfoIndex][2].ToString();
         ReadInfo.textBox4.Text = Set.Tables[0].Rows[InfoIndex][3].ToString();
         ReadInfo.textBox5.Text = Set.Tables[0].Rows[InfoIndex][4].ToString();
     }
     if (Set.Tables[0].Rows[InfoIndex][5] == System.DBNull.Value)
     {
         ReadInfo.pictureBox1.Image   = Image.FromFile("Image/NoPicture.jpg");
         ReadInfo.button5.Enabled     = ReadInfo.button6.Enabled =
             ReadInfo.button8.Enabled = ReadInfo.button9.Enabled =
                 false;
     }
     else
     {
         if (!ReadInfo.button6.Enabled)
         {
             ReadInfo.button5.Enabled     = ReadInfo.button6.Enabled =
                 ReadInfo.button8.Enabled = ReadInfo.button9.Enabled =
                     true;
         }
         try
         {
             ReadInfo.pictureBox1.Image =
                 GetImage((byte[])Set.Tables[0].Rows[InfoIndex][ImageIndex]);
         }
         catch { MessageBox.Show(ImageIndex.ToString()); }
     }
     if (ReadInfo.button6.Enabled)
     {
         if (Heart.ImageIndexMax(InfoIndex, ImageIndex) == 5)
         {
             ReadInfo.button5.Enabled     = ReadInfo.button8.Enabled =
                 ReadInfo.button9.Enabled = false;
         }
         else
         {
             ReadInfo.button5.Enabled     = ReadInfo.button8.Enabled =
                 ReadInfo.button9.Enabled = true;
         }
     }
     End();
 }
Пример #5
0
        static public bool InsertImage(int InfoIndex, int ImageIndex, ReadInfoForm This)
        {
            Start();
            int LastIndex = ImageIndexMax(InfoIndex, ImageIndex) + 1;

            if (LastIndex + 1 > Set.Tables[0].Columns.Count - 1)
            {
                MessageBox.Show(Set.Tables[0].Rows[InfoIndex]["Name"].ToString() +
                                "的照片存储空间已满,请删除其他照片后再添加!");
                return(false);
            }
            else
            {
                byte[]         pictype;
                Stream         S = null;
                OpenFileDialog A = new OpenFileDialog();
                A.Filter = "*.jpg|*.jpg|*.bmp|*.bmp";
                if (A.ShowDialog() == DialogResult.OK)
                {
                    if (A.FileName != "")
                    {
                        S = A.OpenFile();
                        //把图片转为字节数组
                        pictype    = new byte[S.Length];
                        S.Position = 0;
                        S.Read(pictype, 0, Convert.ToInt32(S.Length));

                        //找到最后一个null字段,然后把图片赋给它
                        SqlConnection Con =
                            new SqlConnection("server=.;database=StudentPlus;integrated security=true");
                        Con.Open();
                        SqlCommand    Com      = new SqlCommand("select * from Information", Con);
                        SqlDataReader dr       = Com.ExecuteReader();
                        int           Now      = -1;
                        string        NowField = "";
                        while (dr.Read() && NowField == "")
                        {
                            if (++Now == InfoIndex)//找到当前行
                            {
                                for (int i = 0; i < dr.FieldCount; ++i)
                                {
                                    //最后一个图片之后的字段肯定为null
                                    if (dr.GetValue(i) == System.DBNull.Value)
                                    {
                                        NowField = dr.GetName(i);
                                        break;
                                    }
                                }
                            }
                        }
                        dr.Close();
                        Com.Dispose();
                        Con.Close();

                        Set.Tables[0].Rows[InfoIndex][NowField] = pictype;
                        MessageBox.Show("增加成功", "Insert", MessageBoxButtons.OK);
                        End();
                        Read(InfoIndex, ImageIndexMax(InfoIndex, 5), This);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #6
0
        static public void ChangeImageIndex(bool UpOrDown, int InfoIndex, ref int ImageIndex, ReadInfoForm This)
        {
            int ImageCount = ImageIndexMax(InfoIndex, ImageIndex);

            if (UpOrDown)
            {
                if (++ImageIndex > ImageCount)
                {
                    ImageIndex = 5;
                }
            }
            else
            {
                if (--ImageIndex < 5)
                {
                    ImageIndex = ImageCount;
                }
            }
            Read(InfoIndex, ImageIndex, This);
        }
Пример #7
0
        static public void ChangeInfoIndex(int Key, ref int InfoIndex, ref int ImageIndex, ReadInfoForm This)
        {
            Start();
            switch (Key)
            {
            case 1: if (++InfoIndex == Set.Tables[0].Rows.Count)
                {
                    InfoIndex = 0;
                }
                break;

            case 2: if (--InfoIndex == -1)
                {
                    InfoIndex = Set.Tables[0].Rows.Count - 1;
                }
                break;

            case 3: InfoIndex = 0;
                break;

            case 4: InfoIndex = Set.Tables[0].Rows.Count - 1;
                break;
            }
            Read(InfoIndex, ImageIndex = 5, This);
            End();
        }