Ejemplo n.º 1
0
        private void btn_search_report_Click(object sender, EventArgs e)
        {
            var dateStart = dateTimePicker1.Value;
            var dateEnd   = dateTimePicker2.Value;

            if (_formHelper.FieldsValidationReportSearch(dateStart, dateEnd))
            {
                var result = _database.FindReportByDate(dateStart.ToString(DATE_FORMAT), dateEnd.ToString(DATE_FORMAT));
                if (result.Count == 0)
                {
                    MessageBox.Show(SEARCH_NO_RESULT);
                }
                else
                {
                    dataGridView2.DataSource = result;
                }
            }
            else
            {
                MessageBox.Show(
                    _formHelper.sbErrorMessage.ToString(),
                    "Validation Fields",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                    );
            }
            _formHelper.sbErrorMessage.Clear();
            _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
        }
Ejemplo n.º 2
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            var itemSearch = new DropDownItem
            {
                Filter = cb_search.SelectedItem.ToString(),
                Value  = textBox_Search.Text
            };

            if (_formHelper.FieldsValidationSearch(itemSearch))
            {
                dataGridView1.DataSource = _database.FindByOption(itemSearch);
                PopulateData();
            }
            else
            {
                MessageBox.Show(
                    _formHelper.sbErrorMessage.ToString(),
                    "Validation Fields",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                    );
            }
            _formHelper.sbErrorMessage.Clear();
            _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
        }
Ejemplo n.º 3
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            int?      number    = null;
            CrudModel crudModel = new CrudModel
            {
                ID          = textBox_ID.Text == string.Empty ? number : int.Parse(textBox_ID.Text),
                Name        = textBox_Name.Text,
                Description = textBox_description.Text,
                Image       = GetImageFromView()
            };

            if (_formHelper.FieldsValidationUpdate(crudModel))
            {
                int result = _database.UpdateModel(crudModel);
                ResultOperation(result, UPDATE_SUCCESS);
            }
            else
            {
                MessageBox.Show(
                    _formHelper.sbErrorMessage.ToString(),
                    "Validation Fields",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                    );
            }
            _formHelper.sbErrorMessage.Clear();
            _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
        }
Ejemplo n.º 4
0
        private void dataGridView1_Click(object sender, EventArgs e)
        {
            byte[]       img2 = (byte[])dataGridView1.CurrentRow.Cells[3].Value;
            MemoryStream ms2  = new MemoryStream(img2);

            pictureBox1.Image = System.Drawing.Image.FromStream(ms2);

            textBox_ID.Text          = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            textBox_Name.Text        = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            textBox_description.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
            _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
        }
Ejemplo n.º 5
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     if (_formHelper.FieldsValidationDelete(textBox_ID.Text))
     {
         CrudModel crudModel = new CrudModel {
             ID = int.Parse(textBox_ID.Text)
         };
         int result = _database.DeleteModel(crudModel);
         ResultOperation(result, DELETE_SUCCESS);
     }
     else
     {
         MessageBox.Show(
             _formHelper.sbErrorMessage.ToString(),
             "Validation Fields",
             MessageBoxButtons.OK,
             MessageBoxIcon.Exclamation
             );
     }
     _formHelper.sbErrorMessage.Clear();
     _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
 }
Ejemplo n.º 6
0
        private void btn_add_image_Click(object sender, EventArgs e)
        {
            OpenFileDialog opf = new OpenFileDialog();

            opf.Filter = "Images (*.BMP;*.JPG;*.GIF,*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*";

            if (opf.ShowDialog() == DialogResult.OK)
            {
                if (_formHelper.CanResizeImage(opf))
                {
                    pictureBox1.Image = System.Drawing.Image.FromFile(opf.FileName);
                }
                else
                {
                    MessageBox.Show(
                        "Image can not be bigger than 400Kb!\nPlease choose an image not bigger than 400Kb.",
                        "Image size error.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation
                        );
                }
            }
            _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
        }
Ejemplo n.º 7
0
 private void btn_load_grid_Click(object sender, EventArgs e)
 {
     LoadGridView();
     _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
 }
Ejemplo n.º 8
0
 private void btn_clear_Click(object sender, EventArgs e)
 {
     ClearFields();
     _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
 }
Ejemplo n.º 9
0
        public List <CrudModel> FindByOption(DropDownItem option)
        {
            try
            {
                _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
                string sql;
                switch (option.Filter)
                {
                case "ID":
                {
                    sql = FindByFilter.Replace("@Column", "ID").Replace("@Value", $"{option.Value}");
                    return(_database.FindByOption <CrudModel>(sql));
                }

                case "Name":
                {
                    sql = FindByFilter.Replace("@Column", "Name").Replace("@Value", $"'%{option.Value}%'");
                    var output = _database.FindByOption <CrudModel>(sql);
                    return(output);
                }

                case "Description":
                {
                    sql = FindByFilter.Replace("@Column", "Description").Replace("@Value", $"'%{option.Value}%'");
                    return(_database.FindByOption <CrudModel>(sql));
                }

                default:
                    return(new List <CrudModel>());
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(new List <CrudModel>());
            }
        }
Ejemplo n.º 10
0
 public int DeleteModel(CrudModel crudModel)
 {
     try
     {
         var output = _database.UpdateModel(crudModel, Delete);
         _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
         return(output);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         return(0);
     }
 }
Ejemplo n.º 11
0
 public List <CrudModel> LoadData()
 {
     try
     {
         var output = _database.LoadData <CrudModel>(List);
         _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
         return(output);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         return(new List <CrudModel>());
     }
 }
Ejemplo n.º 12
0
 public List <Report> FindReportByDate(string dateStart, string dateEnd)
 {
     try
     {
         _log.Info(new LogDetails().SetLogClass(this.GetType().Name).SetLogMethod(LogDetails.GetCurrentMethod()));
         string sql;
         sql = FindByDate.Replace("@DateStart", dateStart).Replace("@DateEnd", dateEnd);
         return(_database.FindReportByDate <Report>(sql));
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         return(new List <Report>());
     }
 }