예제 #1
0
파일: MoiveAdd.cs 프로젝트: IrisLinSQ/007
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" &&
                comboBox1.SelectedItem != null && textBox5.Text != "" && textBox6.Text != "" &&
                textBox7.Text != "" && textBox8.Text != "" && pictureBox1.ImageLocation != null)
            {
                Moive moive = new Moive();

                string filePath = @"resource\introduction\" + textBox1.Text.Trim() + "简介.txt";
                string mimage = pictureBox1.ImageLocation;//插入的图片的位置
                string imagePath = @"resource\image\" + textBox1.Text.Trim() + ".png";//复制到目标位置下的地址

                moive.setName(textBox1.Text.Trim());
                moive.setActor(textBox3.Text.Trim());
                moive.setDirector(textBox2.Text.Trim());
                moive.setFare((float)Convert.ToDouble(textBox6.Text.Trim()));
                moive.setLength(Convert.ToInt16(textBox7.Text.Trim()));
                moive.setPutDate(Convert.ToDateTime(textBox5.Text.Trim()));
                moive.setType(comboBox1.SelectedItem.ToString().Trim());

                if (File.Exists(imagePath))
                {
                    File.Delete(imagePath);
                    File.Copy(@mimage, @imagePath);
                }
                else
                {
                    File.Copy(@mimage, @imagePath);
                }

                moive.setImage(imagePath);
                moive.setStory(filePath);

                SqlMoive.addMoive(moive);

                FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);
                sw.Write(textBox8.Text);
                sw.Close();
                fs.Close();

                MessageBox.Show("添加成功");
                cinema.Combox_Load();
                cinema.button3_Click(null, null);
                this.Dispose();
            }
            else
            {
                MessageBox.Show("请输入完整信息!");
            }
        }
예제 #2
0
파일: SqlMoive.cs 프로젝트: IrisLinSQ/007
        public static Moive getMoive(String moiveName)
        {
            Moive moive = new Moive();

            String sql = "select * from Movie where MName='" + moiveName + "'";
            DataSet ds = DbHelperSQL.Query(sql, "Moive");

            moive.setName(ds.Tables["Moive"].Rows[0]["MName"].ToString().Trim());
            moive.setType(ds.Tables["Moive"].Rows[0]["MType"].ToString().Trim());
            moive.setDirector(ds.Tables["Moive"].Rows[0]["MDirector"].ToString().Trim());
            moive.setActor(ds.Tables["Moive"].Rows[0]["MActor"].ToString().Trim());
            moive.setImage(ds.Tables["Moive"].Rows[0]["MImage"].ToString().Trim());
            moive.setStory(ds.Tables["Moive"].Rows[0]["MStory"].ToString().Trim());
            moive.setLength(Convert.ToInt16(ds.Tables["Moive"].Rows[0]["MLength"].ToString().Trim()));
            moive.setPutDate(Convert.ToDateTime(ds.Tables["Moive"].Rows[0]["MPutDay"].ToString().Trim()));
            moive.setFare((float)Convert.ToDouble(ds.Tables["Moive"].Rows[0]["MFare"].ToString().Trim()));

            return moive;
        }