public string Save(ProviderCompany aProviderCompany)
        {
            if (aProviderCompanyDataAccess.IsCodeUnique(aProviderCompany.Name) != null)
            {
                return("Provider or Dealer already exists");
            }
            string msg = aProviderCompanyDataAccess.Save(aProviderCompany);

            return(msg);
        }
 private void initData()
 {
     txtStartDate.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
     txtEndDate.Text   = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
     BindAriline(CurrentCompany.CompanyId);
     BindCity(CurrentCompany.CompanyId, txtDeparture);
     BindCity(CurrentCompany.CompanyId, CityArrival);
     BindSaleRelation();
     BindProductType();
     //IEnumerable<CompanyInitInfo> companies = CompanyService.GetCompanies(CompanyType.Provider, true);
     ProviderCompany.SetCompanyType(CompanyType.Provider, true);
 }
        private void saveProviderCompanyButton_Click(object sender, EventArgs e)
        {
            ProviderCompany aProviderCompany = new ProviderCompany();

            aProviderCompany.Name    = nameProviderCompanyEntryTextBox.Text;
            aProviderCompany.Contact = contactProviderCompnayEntrytextBox.Text;

            ProviderComapnyManager aProviderComapnyManager = new ProviderComapnyManager();
            string msg = aProviderComapnyManager.Save(aProviderCompany);

            MessageBox.Show(msg);
        }
Exemple #4
0
        public string Save(ProviderCompany aProviderCompany)
        {
            string        query         = "INSERT INTO t_provider_company(name, contact) VALUES ('" + aProviderCompany.Name + "','" + aProviderCompany.Contact + "')";
            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);

            sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            return("Provider Company info saved");
        }
Exemple #5
0
        public object IsCodeUnique(string name)
        {
            string        query         = "SELECT * FROM t_provider_company where name = '" + name + "'";
            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                ProviderCompany aProviderCompany = new ProviderCompany();
                aProviderCompany.Name = sqlDataReader[1].ToString();
                sqlConnection.Close();
                return(aProviderCompany);
            }
            sqlConnection.Close();
            return(null);
        }
Exemple #6
0
        public List <ProviderCompany> GetAll()
        {
            string        query         = "SELECT * FROM t_provider_company";
            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();

            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            List <ProviderCompany> providerCompanies = new List <ProviderCompany>();

            while (sqlDataReader.Read())
            {
                ProviderCompany aProviderCompany = new ProviderCompany();
                aProviderCompany.Id      = Convert.ToInt32(sqlDataReader[0]);
                aProviderCompany.Name    = sqlDataReader[1].ToString();
                aProviderCompany.Contact = sqlDataReader[2].ToString();
                providerCompanies.Add(aProviderCompany);
            }
            sqlConnection.Close();
            return(providerCompanies);
        }
Exemple #7
0
 public ProviderCompany Update(ProviderCompany providerCompany)
 {
     _context.ProviderCompany.Update(providerCompany);
     _context.SaveChanges();
     return(providerCompany);
 }
Exemple #8
0
 public ProviderCompany Add(ProviderCompany providerCompany)
 {
     _context.ProviderCompany.Add(providerCompany);
     _context.SaveChanges();
     return(providerCompany);
 }