//const string connString = @"SERVER = TRANSFORMER2\SQLEXPRESS2016; DATABASE = ISLAMBANK; Trusted_Connection = true "; //const string connString = @"SERVER = KUBO\SQLEXPRESS; DATABASE = ISLAMBANK; Trusted_Connection = true "; public int AddAddress(ModelAddress modelAddress) { try { using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); using (SqlCommand command = connection.CreateCommand()) { string sqlQuery = "insert into [ADDRESS] (street,city, postal_code) values(@street, @city, @postcode)"; SqlCommand commandAdd = new SqlCommand(sqlQuery, connection); commandAdd.Parameters.Add("@street", SqlDbType.NVarChar).Value = modelAddress.Street; commandAdd.Parameters.Add("@city", SqlDbType.NVarChar).Value = modelAddress.City; commandAdd.Parameters.Add("@postcode", SqlDbType.NVarChar).Value = modelAddress.PostalCode; if (commandAdd.ExecuteNonQuery() > 0) { using (SqlCommand command1 = connection.CreateCommand()) { command1.CommandText = "Select @@Identity"; return(Convert.ToInt32(command1.ExecuteScalar())); } } } } } catch (Exception) { throw; } return(0); }
public ViewModelAddress(ModelAddress copy) { this.Line1 = copy.Line1; this.Line2 = copy.Line2; this.City = copy.City; this.State = copy.State; this.Zip = copy.Zip; }
public IActionResult Index() { ModelAddress modelAddress = new ModelAddress(); modelAddress.FirstName = "Peter"; modelAddress.LastName = "Long"; return(View(modelAddress)); }
// GET: /<controller>/ public IActionResult Index() { var model = new ModelAddress() { FirstName = "Koyelada", LastName = "Kiran Kumar" }; return(View("Index", model)); }
public bool CreateBankClient(ModelAddress modelAddress, ModelClient modelClient, ModelAccounts modelAccounts) { int addressId = new RepositoryAddress().AddAddress(modelAddress); if (addressId > 0) { int clientId = new RepositoryClient().AddClient(modelClient, addressId); if (clientId > 0) { return(new RepositoryAccount().AddAccount(modelAccounts, clientId)); } } return(false); }
private void button1_Click(object sender, EventArgs e) { randomClient = new LogicAccount().RandomClient(); randomAddress = new LogicAccount().RandomAddress(); txtName.Text = randomClient.FirstName; txtSurname.Text = randomClient.LastName; txtIdentityCard.Text = randomClient.IdentityCard; txtPhone.Text = randomClient.PhoneNumber; txtMail.Text = randomClient.Email; txtStreet.Text = randomAddress.Street; txtCity.Text = randomAddress.City; txtPostCode.Text = randomAddress.PostalCode; }
public ModelAddress GenerateAddress() { string generatedAddress = new Generator().GetRandomAddresses(1).ToList()[0]; string[] parsedAddress = generatedAddress.Split(';'); ModelAddress modelAddress = new ModelAddress() { Street = parsedAddress[0], PostalCode = parsedAddress[1].Replace(" ", String.Empty), City = parsedAddress[2] }; return(modelAddress); }
public ModelAddress SetForUpdate(int addressId) { ModelAddress modelForUpdate = new ModelAddress(); try { using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); using (SqlCommand command = connection.CreateCommand()) { string sqlQuery = @"select [Street] ,[City] ,[Postal_code] from [address] where id=@address"; SqlCommand commandSlct = new SqlCommand(sqlQuery, connection); commandSlct.Parameters.Add("@address", SqlDbType.Int).Value = addressId; using (SqlDataReader reader = commandSlct.ExecuteReader()) { if (reader.Read()) { modelForUpdate.Street = reader.GetString(0); modelForUpdate.City = reader.GetString(1); modelForUpdate.PostalCode = reader.GetString(2); return(modelForUpdate); } } } } } catch (Exception) { throw; } return(modelForUpdate); }
public ActionResult Contact() { return(View(ModelAddress.GetAllFranchiseAddresses())); }