private void FormGenerateLicense_Load(object sender, EventArgs e)
 {
     try
     {
         parent = this.ParentForm as FormMain;
         cboTake.SelectedIndex                 = 9;
         cboUser.SelectedIndex                 = 0;
         cboFollowUpBy.SelectedIndex           = 0;
         dateTimePickerLicenseGenerate.MinDate = DateTime.Today;
         using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
         {
             var season_name = sda.ShowSeasonNameByID(ControlWork.SEASON_ID);
             foreach (var item in season_name)
             {
                 txtSeason.Text = item.SEASON_NAME.ToString();
                 SEASON_ID      = item.SEASON_ID;
             }
         }
         using (TBL_USER_DATA_ACCESS uda = new TBL_USER_DATA_ACCESS())
         {
             cboUser.DataSource          = uda.ShowUserActive();
             cboUser.DisplayMember       = "USERNAME";
             cboUser.ValueMember         = "USER_ID";
             cboFollowUpBy.DataSource    = uda.ShowUserActive();
             cboFollowUpBy.DisplayMember = "USERNAME";
             cboFollowUpBy.ValueMember   = "USER_ID";
         }
         GC.Collect();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
 }
        private void ControlReportLicenseGenerate_Load(object sender, EventArgs e)
        {
            lblHeading.Text             = Properties.Resources.REPORT_LICENSE_GENERATE;
            cboReportName.SelectedIndex = 0;
            try
            {
                using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
                {
                    cboSeason.DataSource    = sda.ShowAllSeasonToComboBox();
                    cboSeason.DisplayMember = "SEASON_NAME";
                    cboSeason.ValueMember   = "SEASON_ID";
                }
                using (TBL_COMPANY_DATA_ACCESS cda = new TBL_COMPANY_DATA_ACCESS())
                {
                    var company = cda.ShowCompany();
                    foreach (var item in company)
                    {
                        COMPANY_NAME    = item.COMPANY_NAME;
                        COMPANY_ADDRESS = item.COMPANY_ADDRESS;
                    }
                }
                printer = new PrinterSettings();

                crxApp    = new CRAXDDRT.Application();
                crxReport = new CRAXDDRT.Report();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 3
0
 private void FormUpdateSeason_Load(object sender, EventArgs e)
 {
     using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
     {
         foreach (var item in sda.CheckSeasonWithoutExisting(txtSeasonName.Text))
         {
             SEASON_NAME = item.SEASON_NAME;
             MessageBox.Show(SEASON_NAME);
         }
     }
     try
     {
         using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
         {
             foreach (var item in sda.ShowSeasonNameByID(Convert.ToInt32(ControlSeason.SEASON_ID)))
             {
                 txtSeasonName.Text = item.SEASON_NAME;
                 txtNote.Text       = item.NOTE;
                 txtCreateBy.Text   = item.CREATE_BY;
                 SEASON_ID          = item.SEASON_ID;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
     GC.Collect();
 }
 private void btnAddNew_Click(object sender, EventArgs e)
 {
     try
     {
         btnAddNew.UseSelectable = false;
         using (_addseason = new FormAddNewSeason())
         {
             _addseason.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
         GC.Collect();
     }
     finally
     {
         using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
         {
             dataGridViewSeason.DataSource = sda.ShowAllSeasonIncludeInactive();
         }
         GC.Collect();
     }
     btnAddNew.UseSelectable = false;
 }
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     SEASON_ID = 0;
     btnUpdate.UseSelectable = false;
     try
     {
         foreach (DataGridViewRow row in dataGridViewSeason.SelectedRows)
         {
             SEASON_ID = Convert.ToInt32(row.Cells[0].Value);
         }
         //MessageBox.Show(SEASON_ID.ToString());
         if (SEASON_ID != 0)
         {
             FormUpdateSeason update = new FormUpdateSeason();
             update.ShowDialog(this);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
     finally
     {
         using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
         {
             dataGridViewSeason.DataSource = sda.ShowAllSeasonIncludeInactive();
         }
     }
 }
Exemplo n.º 6
0
        private bool Invalid()
        {
            bool flag = false;

            using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
            {
                foreach (var item in sda.CheckSeason(txtSeasonName.Text))
                {
                    SEASON_NAME = item.SEASON_NAME;
                }
            }
            if (txtSeasonName.Text == SEASON_NAME)
            {
                this.txtSeasonName.SetValidation(string.Format(Properties.Resources.SEASON_AREADY, this.label1.Text));
                flag = true;
                txtSeasonName.Focus();
            }
            if (txtSeasonName.Text == string.Empty)
            {
                this.txtSeasonName.SetValidation(string.Format(Properties.Resources.REQUIRED_SEASON, this.label1.Text));
                flag = true;
                txtSeasonName.Focus();
            }
            using (TBL_USER_DATA_ACCESS uda = new TBL_USER_DATA_ACCESS())
            {
                if (!uda.Authentication(cboUser.Text, txtPassword.Text.Trim()))
                {
                    this.txtPassword.SetValidation(string.Format(Properties.Resources.WRONG_PASSWORD, this.label1.Text));
                    flag = true;
                    txtPassword.Focus();
                }
            }

            return(flag);
        }
 private void ControlSeason_Load(object sender, EventArgs e)
 {
     using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
     {
         dataGridViewSeason.DataSource = sda.ShowAllSeasonIncludeInactive();
     }
 }
Exemplo n.º 8
0
 private void FormAddNewSeason_Load(object sender, EventArgs e)
 {
     try
     {
         ListSchedule          = new List <int>();
         cboUser.SelectedIndex = 0;
         using (TBL_USER_DATA_ACCESS uda = new TBL_USER_DATA_ACCESS())
         {
             cboUser.DataSource    = uda.ShowUserActive();
             cboUser.DisplayMember = "USERNAME";
             cboUser.ValueMember   = "USER_ID";
         }
         using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
         {
             foreach (var item in sda.ShowAllLicense())
             {
                 ListSchedule.Add(item.LICENSE_ID);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
 }
 private void cboSeason_SelectedIndexChanged(object sender, EventArgs e)
 {
     using (sda = new TBL_SEASON_DATA_ACCESS())
     {
         foreach (var item in sda.ShowSeason(Convert.ToInt32(cboSeason.SelectedValue)))
         {
             lblRemainNumber.Text = item.REMAIN_LICENSE.ToString();
         }
         dataGridViewSurvey.DataSource = sda.ShowSurvey(Convert.ToInt32(cboSeason.SelectedValue));
     }
 }
 private void ControlSurvey_Load(object sender, EventArgs e)
 {
     cboSeason.SelectedIndexChanged -= new EventHandler(cboSeason_SelectedIndexChanged);
     using (sda = new TBL_SEASON_DATA_ACCESS())
     {
         cboSeason.DataSource          = sda.ShowAllSeason();
         cboSeason.DisplayMember       = "SEASON_NAME";
         cboSeason.ValueMember         = "SEASON_ID";
         dataGridViewSurvey.DataSource = sda.ShowSurvey(Convert.ToInt32(cboSeason.SelectedValue));
     }
     cboSeason.SelectedIndexChanged += new EventHandler(cboSeason_SelectedIndexChanged);
 }
        private void ControlWork_Load(object sender, EventArgs e)
        {
            cboSeason.SelectedIndexChanged -= new EventHandler(cboSeason_SelectedIndexChanged);
            TBL_SCHEDULE_DATA_ACCESS sda  = new TBL_SCHEDULE_DATA_ACCESS();
            TBL_SEASON_DATA_ACCESS   seda = new TBL_SEASON_DATA_ACCESS();

            cboSeason.DataSource            = seda.ShowSeason();
            cboSeason.DisplayMember         = "SEASON_NAME";
            cboSeason.ValueMember           = "SEASON_ID";
            dataGridViewGenerate.DataSource = sda.DisplayToGenerate(Convert.ToInt32(cboSeason.SelectedValue));
            cboSeason.SelectedIndexChanged += new EventHandler(cboSeason_SelectedIndexChanged);
        }
Exemplo n.º 12
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!Invalid())
     {
         try
         {
             using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
             {
                 using (_context = new LicenseDataContext())
                 {
                     TBL_SEASON season = new TBL_SEASON()
                     {
                         SEASON_NAME = txtSeasonName.Text,
                         CREATE_BY   = cboUser.Text,
                         IS_ACTIVE   = true,
                         CREATE_DATE = DateTime.Now,
                         NOTE        = txtNote.Text.Trim()
                     };
                     sda.SaveSeason(season);
                     foreach (var item in sda.ShowSeasonNameByName(txtSeasonName.Text))
                     {
                         SEASON_ID = item.SEASON_ID;
                     }
                     TBL_SCHEDULE schedule = new TBL_SCHEDULE();
                     foreach (var item in ListSchedule)
                     {
                         schedule.LICENSE_ID = item;
                         schedule.SEASON_ID  = SEASON_ID;
                         sda.SaveSchedule(schedule);
                     }
                     this.Close();
                 };
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
         }
     }
     else
     {
     }
 }
Exemplo n.º 13
0
        public bool Invalid()
        {
            bool flag = false;

            using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
            {
                foreach (var item in sda.CheckSeasonWithoutExisting(txtSeasonName.Text))
                {
                    SEASON_NAME = item.SEASON_NAME;
                    MessageBox.Show(SEASON_NAME);
                    if (txtSeasonName.Text == SEASON_NAME)
                    {
                        this.txtSeasonName.SetValidation(string.Format(Properties.Resources.SEASON_AREADY, this.label1.Text));
                        flag = true;
                        txtSeasonName.Focus();
                    }
                }
            }

            return(flag);
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     SEASON_ID = 0;
     try
     {
         foreach (DataGridViewRow row in dataGridViewSeason.SelectedRows)
         {
             SEASON_ID = Convert.ToInt32(row.Cells[0].Value);
         }
         //MessageBox.Show(SEASON_ID.ToString());
         if (SEASON_ID != 0)
         {
             using (LicenseDataContext _context = new LicenseDataContext())
             {
                 TBL_SEASON season = (from s in _context.TBL_SEASONs
                                      where s.SEASON_ID == SEASON_ID
                                      select s).FirstOrDefault();
                 season.IS_ACTIVE = false;
                 _context.SubmitChanges();
             };
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
         GC.Collect();
     }
     finally
     {
         using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
         {
             dataGridViewSeason.DataSource = sda.ShowAllSeasonIncludeInactive();
         }
     }
     btnDelete.UseSelectable = false;
 }
        public void ckShowAllSeason_CheckedChanged(object sender, EventArgs e)
        {
            // by Sieng Sotheara 2016-4-28
            if (ckShowAllSeason.Checked == true)
            {
                using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
                {
                    DataTable dt = new DataTable();

                    dt.Columns.Add("SEASON_ID");
                    dt.Columns.Add("SEASON_NAME");
                    DataRow row1 = dt.NewRow();
                    row1[0] = 0;
                    row1[1] = Properties.Resources.ALL_SEASON;
                    dt.Rows.Add(row1);
                    foreach (var item in sda.ShowAllSeason())
                    {
                        DataRow row = dt.NewRow();
                        row[0] = item.SEASON_ID;
                        row[1] = item.SEASON_NAME;
                        dt.Rows.Add(row);
                    }
                    cboSeason.DataSource    = dt;
                    cboSeason.DisplayMember = "SEASON_NAME";
                    cboSeason.ValueMember   = "SEASON_ID";
                };
            }
            else
            {
                using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
                {
                    cboSeason.DataSource = sda.ShowSeason();
                };
            }
            GC.Collect();
        }