Exemplo n.º 1
0
        private void dataGridViewCompany_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                var id = Convert.ToInt32(dataGridViewCompany.CurrentRow.Cells[0].Value.ToString());

                using (var _context = new STLxEntities())
                {
                    var source = _context.Companies.FirstOrDefault(i => i.Id == id);

                    if (!string.IsNullOrEmpty(source.Code))
                    {
                        TextBoxCode.Text = source.Code;
                        TextBoxName.Text = source.Name;

                        ButtonEdit.Enabled   = true;
                        ButtonDelete.Enabled = true;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 2
0
 private void BindCompanyWithDataGrid()
 {
     try
     {
         using (var _context = new STLxEntities())
         {
             var source = _context.Companies.Where(e => e.Name.Contains(TextBoxSearch.Text) &&
                                                   e.Status != false &&
                                                   e.IsDelete != true);
             dataGridViewCompany.DataSource = source.ToList();
         }
     }
     catch (Exception)
     {
         return;
     }
 }
Exemplo n.º 3
0
 private void ButtonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         using (var _context = new STLxEntities())
         {
             var emp = _context.Companies.First(i => i.Code == TextBoxCode.Text);
             emp.IsDelete = true;
             _context.SaveChanges();
             BindCompanyWithDataGrid();
             MessageBox.Show("Company was deleted");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("No company is deleted, Contact Admin.");
     }
 }
Exemplo n.º 4
0
 private void EditCompany()
 {
     try
     {
         using (var _context = new STLxEntities())
         {
             var company = _context.Companies.First(e => e.Code == TextBoxCode.Text);
             company.Code   = TextBoxCode.Text;
             company.Name   = TextBoxName.Text;
             company.Status = "YES".Equals(ComboBoxStatus.Text.Trim());
             _context.SaveChanges();
             ResetControls();
             MessageBox.Show("Company was updated");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error on editing company.");
     }
 }
Exemplo n.º 5
0
 private void SaveCompany()
 {
     try
     {
         using (var _context = new STLxEntities())
         {
             var company = new Data.Company()
             {
                 Code     = TextBoxCode.Text,
                 Name     = TextBoxName.Text,
                 Status   = true,
                 IsDelete = false
             };
             _context.Companies.Add(company);
             _context.SaveChanges();
             ResetControls();
             MessageBox.Show("Company Save");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Company not save");
     }
 }
Exemplo n.º 6
0
 public WithoutBankAccount()
 {
     _context = new STLxEntities();
 }