예제 #1
0
        protected void SaveInvoicePreparationProgress()
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            Facade.IInvoice facProgress = new Facade.Invoice();

            if (ViewState["invoicePreparation"] == null)
            {
                m_InvoicePreparation = new Entities.InvoicePreparation();
            }
            else
            {
                m_InvoicePreparation = (Entities.InvoicePreparation)ViewState["invoicePreparation"];
            }

            // Params
            if (cboClient.SelectedValue != "")
            {
                m_InvoicePreparation.ClientId = Convert.ToInt32(cboClient.SelectedValue);
            }

            if (dteStartDate.SelectedDate == DateTime.MinValue)
            {
                m_InvoicePreparation.StartDate = DateTime.MinValue;
            }
            else
            {
                m_InvoicePreparation.StartDate = dteStartDate.SelectedDate.Value;
            }

            if (dteEndDate.SelectedDate == DateTime.MinValue)
            {
                m_InvoicePreparation.EndDate = DateTime.MinValue;
            }
            else
            {
                m_InvoicePreparation.EndDate = dteEndDate.SelectedDate.Value;
            }

            m_selectedJobs = GetJobsSelected();
            m_InvoicePreparation.JobIdCSV = hidSelectedJobs.Value;
            m_InvoicePreparation.JobState = ((eJobState)cboJobState.SelectedIndex + 1);
            m_InvoicePreparation.UserName = userName;

            bool saved = false;

            if (dteStartDate.SelectedDate == DateTime.MinValue || dteEndDate.SelectedDate == DateTime.MinValue)
            {
                saved = facProgress.SaveInvoicePreparationProgress(m_InvoicePreparation);
            }
            else
            {
                saved = facProgress.SaveInvoicePreparationProgressWithDates(m_InvoicePreparation);
            }

            if (saved)
            {
                lblSaveProgressNotification.Visible   = true;
                lblSaveProgressNotification.ForeColor = Color.Blue;
                lblSaveProgressNotification.Text      = "You have successfully saved the progress filter.";
                LoadGrid();
            }
            else
            {
                lblSaveProgressNotification.Visible   = true;
                lblSaveProgressNotification.ForeColor = Color.Red;
                lblSaveProgressNotification.Text      = "The unable to save the progress filter.";
            }
        }