Exemple #1
0
        /// <summary>
        /// 复制事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsCopy_Click(object sender, EventArgs e)
        {
            DateTime        dtNow = dtDateTime.Value;
            frmCopyShowPlan frm   = new frmCopyShowPlan(dataManager, txtTheter.Text);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                //数组保存顺序:
                //(0)被复制信息的日期
                //(1)被复制信息的影厅(null表示复制全部影厅)
                //(2)目标日期
                //(3)目标影厅(null表示复制全部影厅)
                string[] str = frm.GetStr;
                if (str[0] == str[2] || spPanShowPlan.IsSave == true)
                {
                    try
                    {
                        //检查是否符合复制的要求
                        try
                        {
                            dataManager.CheckCopy(str);
                        }
                        catch (Exception info)
                        {
                            if (info.Message.EndsWith("?") == true)
                            {
                                if (MessageBox.Show(info.Message, "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                {
                                    return;
                                }
                            }
                            else
                            {
                                throw new NotImplementedException(info.Message);
                            }
                        }

                        string mess;
                        if (str[1] != null && str[3] != null)
                        {
                            mess = string.Format("确定将日期为:{0} 的 {1} 影厅的放映计划复制到日期为:{2} 的 {3} 影厅",
                                                 str[0], dataManager.DailyShowPlan.HallList.Where(P => P.HallId == str[1]).FirstOrDefault().HallName, str[2], dataManager.DailyShowPlan.HallList.Where(P => P.HallId == str[3]).FirstOrDefault().HallName);
                        }
                        else
                        {
                            mess = string.Format("确定将日期为:{0} 的 {1} 影厅的放映计划复制到日期为:{2} 的 {1} 影厅", str[0], "全部", str[2]);
                        }
                        if (MessageBox.Show(mess, "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                        {
                            return;
                        }
                        if (str[0] != str[2])
                        {
                            dtDateTime.Value = Convert.ToDateTime(str[2]);
                        }

                        //复制放映计划

                        dataManager.CopyShowPlan(str);

                        //刷新放映计划
                        spPanShowPlan.RefreshShowPlan();

                        //改变保存状态
                        spPanShowPlan.IsSave = false;

                        if (str[3] != null)
                        {
                            spPanShowPlan.SetPage(Convert.ToInt32(str[3]) / 7 + 1);
                            tsCopy.Enabled = true;
                        }
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show(error.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("当前日期的放映计划还没保存,不能复制!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }