private void createButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtCompanyName.Text))
     {
         MessageBox.Show("Please enter Company Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtCompanyName.Focus();
         return;
     }
     try
     {
         con = new SqlConnection(cs.DBConn);
         con.Open();
         string ct3 = "select Company.CompanyName from Company";
         cmd = new SqlCommand(ct3, con);
         rdr = cmd.ExecuteReader();
         if (rdr.Read() && !rdr.IsDBNull(0))
         {
             MessageBox.Show("It is not possible to create more than one company.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             con.Close();
             return;
         }
         else
         {
             CompanyGateway aComGateway = new CompanyGateway();
             Company        aCompany    = new Company();
             aCompany.CompanyName     = txtCompanyName.Text;
             aCompany.CreatedDateTime = DateTime.UtcNow;
             string msg = aComGateway.SaveCompany(aCompany);
             MessageBox.Show(msg);
             txtCompanyName.Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
 public CompanyManager()
 {
     companyGateway = new CompanyGateway();
 }
Exemple #3
0
 public ItemManager()
 {
     itemGateway     = new ItemGateway();
     companyGateway  = new CompanyGateway();
     categoryGateway = new CategoryGateway();
 }