Exemple #1
0
        private void txtTheaterName_TextChanged(object sender, EventArgs e)
        {
            if (txtTheaterId.Text != string.Empty && txtTheaterName.Text != string.Empty &&
                txtHalls.Text != string.Empty && txtSeatsAll.Text != string.Empty)
            {
                string str = txtTheaterId.Text + "," + txtTheaterName.Text + "," + txtHalls.Text + "," + txtSeatsAll.Text;
                str = RC6Encryption.Encrypt(str, 256);
                if (str.Length >= 25)
                {
                    txtSerialNumber.Text = str.Substring(0, 25);
                }
                else
                {
                    txtSerialNumber.Text = str;
                }

                TheaterInfo.SerialNumber = txtSerialNumber.Text.Trim();
            }
        }
Exemple #2
0
        /// <summary>
        /// 保存XML文档
        /// </summary>
        private void SaveXML()
        {
            DataSet ds = new DataSet("TheaterAndHall");

            DataTable dtTime = new DataTable("dtTime");

            dtTime.Columns.Add("StartTime");
            dtTime.Columns.Add("EndTime");
            DataRow dw = dtTime.NewRow();

            dw["StartTime"] = dtpStart.Value.Date;
            dw["EndTime"]   = dtpEnd.Value.Date.AddDays(1).AddSeconds(-1);
            dtTime.Rows.Add(dw);
            ds.Tables.Add(dtTime);


            DataTable dtModule = new DataTable("dtModule");

            dtModule.Columns.Add("Name");
            dtModule.Columns.Add("Value");
            dtModule = SaveModule(dtModule);
            ds.Tables.Add(dtModule);

            DataTable TheaterInformation = new DataTable("TheaterInformation");


            //由于下面的方法只支持List,所以在此先定义一个中间变量
            List <CustomDataTypes.TheaterInfo> TheaterList = new List <CustomDataTypes.TheaterInfo>();

            TheaterList.Add(TheaterInfo);
            if (TheaterList.Count > 0)
            {
                PropertyInfo[] propertys = TheaterList[0].GetType().GetProperties();
                foreach (PropertyInfo pi in propertys)
                {
                    //获取DailyPlan表的标题名称
                    TheaterInformation.Columns.Add(pi.Name);//, pi.PropertyType
                }

                for (int i = 0; i < TheaterList.Count; i++)
                {
                    //获取数据
                    ArrayList tempList = new ArrayList();
                    foreach (PropertyInfo pi in propertys)
                    {
                        object obj = pi.GetValue(TheaterList[i], null);
                        tempList.Add(obj);
                    }
                    object[] array = tempList.ToArray();
                    TheaterInformation.LoadDataRow(array, true);
                }
            }
            DataTable HallInformation = new DataTable("HallInformation");

            hallList = dataBindingSource.DataSource as List <CustomDataTypes.HallInfo>;
            if (hallList.Count > 0)
            {
                PropertyInfo[] propertys = hallList[0].GetType().GetProperties();
                foreach (PropertyInfo pi in propertys)
                {
                    //获取DailyPlan表的标题名称
                    HallInformation.Columns.Add(pi.Name);//, pi.PropertyType
                }

                for (int i = 0; i < hallList.Count; i++)
                {
                    //获取数据
                    ArrayList tempList = new ArrayList();
                    foreach (PropertyInfo pi in propertys)
                    {
                        object obj = pi.GetValue(hallList[i], null);
                        tempList.Add(obj);
                    }
                    object[] array = tempList.ToArray();
                    HallInformation.LoadDataRow(array, true);
                }
            }
            ds.Tables.Add(TheaterInformation);

            //将放映计划信息信息加入到dataset中
            ds.Tables.Add(HallInformation);

            //导出XML文件
            ds.WriteXml(Path);

            StreamReader sr = new StreamReader(Path);
            string       ss = RC6Encryption.Encrypt(sr.ReadToEnd());

            sr.Dispose();
            sr.Close();

            StreamWriter sw = new StreamWriter(Path, false);

            sw.Write(ss);
            sw.Flush();
            sw.Dispose();
            sw.Close();
        }