Ejemplo n.º 1
0
        public static Form ShowFormByName(string formName, out bool isLogout)
        {
            Form form             = null;
            bool isFunctionLogout = false;

            if (!string.IsNullOrWhiteSpace(formName))
            {
                formName = formName.Trim();

                //Check if form is opened
                if (OpenedForms.Contains(formName))
                {
                    form = (Form)OpenedForms[formName];
                    form.Dispose();
                    if (form.IsDisposed)
                    {
                        OpenedForms.Remove(formName);
                        form = null;
                    }
                }

                switch (formName)
                {
                case "Danh mục khách hàng":
                    ListCustomerForm listCustomerForm = new ListCustomerForm();
                    form = (Form)listCustomerForm;
                    break;

                case "Danh mục loại quảng cáo":
                    ListShowTypeForm listShowTypeForm = new ListShowTypeForm();
                    form = (Form)listShowTypeForm;
                    break;

                case "Danh mục buổi phát":
                    ListSessionForm listSessionForm = new ListSessionForm();
                    form = (Form)listSessionForm;
                    break;

                case "Danh mục thời điểm":
                    ListTimeSlotForm listTimeSlotForm = new ListTimeSlotForm();
                    form = (Form)listTimeSlotForm;
                    break;

                case "Danh mục thời lượng":
                    ListDurationForm listDurationForm = new ListDurationForm();
                    form = (Form)listDurationForm;
                    break;

                //Nhập liệu
                case "Hợp đồng quảng cáo":
                    ListContractForm listContractForm = new ListContractForm();
                    form = (Form)listContractForm;
                    break;

                case "Xếp lịch theo ngày":
                    SortScheduleByDayForm sortScheduleByDayForm = new SortScheduleByDayForm();
                    form = (Form)sortScheduleByDayForm;
                    break;

                //In ấn
                case "In lịch phát sóng":
                    SchedulePrintForm schedulePrintForm = new SchedulePrintForm();
                    form = (Form)schedulePrintForm;
                    break;

                case "Báo cáo doanh thu":
                    RevenuePrintForm revenuePrintForm = new RevenuePrintForm();
                    form = (Form)revenuePrintForm;
                    break;

                case "Đối chiếu công nợ":
                    LiabilitesPrintForm liabilitesPrintForm = new LiabilitesPrintForm();
                    form = (Form)liabilitesPrintForm;
                    break;

                case "Chứng nhận phát sóng":
                    ShowCommitmentPrintForm showCommitmentPrintForm = new ShowCommitmentPrintForm();
                    form = (Form)showCommitmentPrintForm;
                    break;

                case "Dự trù thời lượng":
                    ExpectedPrintForm expectedPrintForm = new ExpectedPrintForm();
                    form = (Form)expectedPrintForm;
                    break;

                case "Đăng ký quảng cáo":
                    InputSchedulePrintForm inputSchedulePrintForm = new InputSchedulePrintForm();
                    form = (Form)inputSchedulePrintForm;
                    break;

                case "Bảng giá quảng cáo":
                    PricingPrintForm pricingPrintForm = new PricingPrintForm();
                    form = (Form)pricingPrintForm;
                    break;

                //Trợ giúp
                case "Đổi mật khẩu":
                    ChangePasswordForm changePasswordForm = new ChangePasswordForm();
                    form = (Form)changePasswordForm;
                    break;

                case "Thông tin ứng dụng":
                    HelpForm helpForm = new HelpForm();
                    form = (Form)helpForm;
                    break;

                //Quyền Admin
                case "Đặt lại mật khẩu":
                    ResetPasswordForm resetPasswordForm = new ResetPasswordForm();
                    form = (Form)resetPasswordForm;
                    break;

                case "Xem lịch sử":
                    LoggingForm loggingForm = new LoggingForm();
                    form = (Form)loggingForm;
                    break;

                case "Tạo tài khoản":
                    CreateAccountForm createAccountForm = new CreateAccountForm();
                    form = (Form)createAccountForm;
                    break;

                case "Logout":
                    Session.Logout();
                    isFunctionLogout = true;
                    break;

                case "Exit":
                    Application.Exit();
                    break;
                }

                if (form != null)
                {
                    form.Owner         = GlobalForm.ActiveForm;
                    form.MdiParent     = GlobalForm.ActiveForm;
                    form.ShowInTaskbar = true;
                    form.BringToFront();
                    form.TopMost       = true;
                    form.MinimizeBox   = true;
                    form.WindowState   = FormWindowState.Normal;
                    form.StartPosition = FormStartPosition.CenterScreen;

                    form.Show();

                    if (!OpenedForms.Contains(formName))
                    {
                        OpenedForms.Add(formName, form);
                    }
                }
            }

            isLogout = isFunctionLogout;
            return(form);
        }
Ejemplo n.º 2
0
        public static Form OpenFormByName(string formName, out bool isLogout)
        {
            Form form             = null;
            bool isFunctionLogout = false;

            if (!string.IsNullOrWhiteSpace(formName))
            {
                formName = formName.Trim();

                //Check if form is opened
                if (OpenedForms.Contains(formName))
                {
                    form = (Form)OpenedForms[formName];
                    form.Dispose();
                    if (form.IsDisposed)
                    {
                        OpenedForms.Remove(formName);
                        form = null;
                    }
                }

                switch (formName)
                {
                case "Danh mục khách hàng":
                    ListCustomerForm listCustomerForm = new ListCustomerForm();
                    form = (Form)listCustomerForm;
                    break;
                //case "Advertisement":
                //    AdvertisementForm advertisementForm = new AdvertisementForm();
                //    form = (Form)advertisementForm;
                //    break;

                case "Logout":
                    Session.Logout();
                    isFunctionLogout = true;
                    break;

                case "Exit":
                    Application.Exit();
                    break;
                }

                if (form != null)
                {
                    form.Owner         = GlobalForm.ActiveForm;
                    form.MdiParent     = GlobalForm.ActiveForm;
                    form.ShowInTaskbar = true;
                    form.BringToFront();
                    form.TopMost       = true;
                    form.MinimizeBox   = true;
                    form.WindowState   = FormWindowState.Normal;
                    form.StartPosition = FormStartPosition.CenterScreen;

                    form.Show();

                    if (!OpenedForms.Contains(formName))
                    {
                        OpenedForms.Add(formName, form);
                    }
                }
            }

            isLogout = isFunctionLogout;
            return(form);
        }