public bool UpdateCompanyData(CompanyMaintanance oCompanyMaintanance) { bool ReturnValue = false; try { using (HttpClient client = new HttpClient()) { string path = "Company/UpdateCompanyData"; client.BaseAddress = new Uri(GlobalValues.BaseUri); var json = JsonConvert.SerializeObject(oCompanyMaintanance); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage responce = client.PostAsync(path, content).Result; if (responce.IsSuccessStatusCode) { string jsnString = responce.Content.ReadAsStringAsync().Result; ReturnValue = JsonConvert.DeserializeObject <bool>(jsnString); } } } catch (Exception ex) { string message = ex.Message; } return(ReturnValue); }
public bool CompanyUpdate(CompanyMaintanance oCompanyMaintanance) { CompanyDTO oCompanyDTOs = oCompanyMaintanance.oCompanyDTO; LoginDTO oLoginDTOs = oCompanyMaintanance.oLoginDTO; int resultCount = 0; try { using (UniversalConnection oUniversalConnection = new UniversalConnection(Connection.Common.ConnectionString)) { oUniversalConnection.Parameters.Clear(); StringBuilder varname1 = new StringBuilder(); varname1.Append("UPDATE Company \n"); varname1.Append("SET \n"); varname1.Append(" Name = ?Name, \n"); varname1.Append(" Address = ?Address, \n"); varname1.Append(" Telephone = ?Telephone, \n"); varname1.Append(" Email = ?Email, \n"); varname1.Append(" Description = ?Description, \n"); varname1.Append(" Type = ?Type, \n"); varname1.Append(" NumberOfShares = ?NumberOfShares, \n"); varname1.Append(" SharePrice = ?SharePrice, \n"); varname1.Append(" Status = ?Status, \n"); varname1.Append(" UserName = ?UserName, \n"); varname1.Append(" Password = ?Password, \n"); varname1.Append(" ModifiedUser = ?ModifiedUser, \n"); varname1.Append(" ModifiedMachine = ?ModifiedMachine, \n"); varname1.Append(" ModifiedDateTime = ?ModifiedDateTime \n"); varname1.Append(" WHERE CompanyId = ?CompanyId"); oUniversalConnection.CommandText = varname1.ToString(); oUniversalConnection.Parameters.Add(new Parameter { Name = "CompanyId", Value = (object)oCompanyDTOs.CompanyId ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Name", Value = (object)oCompanyDTOs.Name ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Address", Value = (object)oCompanyDTOs.Address ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Telephone", Value = (object)oCompanyDTOs.Telephone ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Email", Value = (object)oCompanyDTOs.Email ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Description", Value = (object)oCompanyDTOs.Description ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Type", Value = (object)oCompanyDTOs.Type ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "NumberOfShares", Value = (object)oCompanyDTOs.NumberOfShares ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "SharePrice", Value = (object)oCompanyDTOs.SharePrice ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Status", Value = (object)oCompanyDTOs.Status ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "UserName", Value = (object)oCompanyDTOs.UserName ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Password", Value = (object)oCompanyDTOs.Password ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedUser", Value = (object)oCompanyDTOs.ModifiedUser ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedMachine", Value = (object)oCompanyDTOs.ModifiedMachine ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = (object)oCompanyDTOs.ModifiedDateTime ?? DBNull.Value }); resultCount = oUniversalConnection.ExecuteQuery(); StringBuilder varname2 = new StringBuilder(); varname2.Append("UPDATE Users \n"); varname2.Append(" SET [UserName] = ?UserName \n"); varname2.Append(" ,[Password] = ?Password \n"); varname2.Append(" ,[UserType] = ?UserType \n"); varname2.Append(" ,[LoginAttempts] = ?LoginAttempts \n"); varname2.Append(" ,[ModifiedUser] = ?ModifiedUser \n"); varname2.Append(" ,[ModifiedMachine] = ?ModifiedMachine \n"); varname2.Append(" ,[ModifiedDateTime] = ?ModifiedDateTime \n"); varname2.Append("WHERE UserName = ?UserName \n"); oUniversalConnection.CommandText = varname2.ToString(); oUniversalConnection.Parameters.Clear(); oUniversalConnection.Parameters.Add(new Parameter { Name = "UserName", Value = (object)oLoginDTOs.UserName ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Password", Value = (object)oLoginDTOs.Password ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "UserType", Value = (object)oLoginDTOs.UserType ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "LoginAttempts", Value = (object)oLoginDTOs.LoginAttempts ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedUser", Value = (object)oLoginDTOs.ModifiedUser ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedMachine", Value = (object)oLoginDTOs.ModifiedMachine ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = (object)oLoginDTOs.ModifiedDateTime ?? DBNull.Value }); oUniversalConnection.ExecuteQuery(); } return(resultCount > 0); } catch (Exception ex) { Logger.Write(ex); throw ex; } }
public bool CompanyInsert(CompanyMaintanance oCompanyMaintanance) { CompanyDTO oCompanyDTOs = oCompanyMaintanance.oCompanyDTO; LoginDTO oLoginDTOs = oCompanyMaintanance.oLoginDTO; int resultCount = 0; try { using (UniversalConnection oUniversalConnection = new UniversalConnection(Connection.Common.ConnectionString)) { StringBuilder varname1 = new StringBuilder(); varname1.Append("INSERT INTO Company \n"); varname1.Append(" (Name, \n"); varname1.Append(" Address, \n"); varname1.Append(" Telephone, \n"); varname1.Append(" Email, \n"); varname1.Append(" Description, \n"); varname1.Append(" Type, \n"); varname1.Append(" NumberOfShares, \n"); varname1.Append(" SharePrice, \n"); varname1.Append(" Status, \n"); varname1.Append(" UserName, \n"); varname1.Append(" Password, \n"); varname1.Append(" CreatedUser, \n"); varname1.Append(" CreatedMachine, \n"); varname1.Append(" CreatedDateTime, \n"); varname1.Append(" ModifiedUser, \n"); varname1.Append(" ModifiedMachine, \n"); varname1.Append(" ModifiedDateTime) \n"); varname1.Append("VALUES (?Name, \n"); varname1.Append(" ?Address, \n"); varname1.Append(" ?Telephone, \n"); varname1.Append(" ?Email, \n"); varname1.Append(" ?Description, \n"); varname1.Append(" ?Type, \n"); varname1.Append(" ?NumberOfShares, \n"); varname1.Append(" ?SharePrice, \n"); varname1.Append(" ?Status, \n"); varname1.Append(" ?UserName, \n"); varname1.Append(" ?Password, \n"); varname1.Append(" ?CreatedUser, \n"); varname1.Append(" ?CreatedMachine, \n"); varname1.Append(" ?CreatedDateTime, \n"); varname1.Append(" ?ModifiedUser, \n"); varname1.Append(" ?ModifiedMachine, \n"); varname1.Append(" ?ModifiedDateTime)"); oUniversalConnection.CommandText = varname1.ToString(); oUniversalConnection.Parameters.Clear(); oUniversalConnection.Parameters.Add(new Parameter { Name = "Name", Value = (object)oCompanyDTOs.Name ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Address", Value = (object)oCompanyDTOs.Address ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Telephone", Value = (object)oCompanyDTOs.Telephone ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Email", Value = (object)oCompanyDTOs.Email ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Description", Value = (object)oCompanyDTOs.Description ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Type", Value = (object)oCompanyDTOs.Type ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "NumberOfShares", Value = (object)oCompanyDTOs.NumberOfShares ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "SharePrice", Value = (object)oCompanyDTOs.SharePrice ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Status", Value = (object)oCompanyDTOs.Status ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "UserName", Value = (object)oCompanyDTOs.UserName ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Password", Value = (object)oCompanyDTOs.Password ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "CreatedUser", Value = (object)oCompanyDTOs.CreatedUser ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "CreatedMachine", Value = (object)oCompanyDTOs.CreatedMachine ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "CreatedDateTime", Value = (object)oCompanyDTOs.CreatedDateTime ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedUser", Value = (object)oCompanyDTOs.ModifiedUser ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedMachine", Value = (object)oCompanyDTOs.ModifiedMachine ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = (object)oCompanyDTOs.ModifiedDateTime ?? DBNull.Value }); resultCount = oUniversalConnection.ExecuteQuery(); StringBuilder varname2 = new StringBuilder(); varname2.Append("INSERT INTO Users \n"); varname2.Append(" (UserName, \n"); varname2.Append(" Password, \n"); varname2.Append(" UserType, \n"); varname2.Append(" LoginAttempts, \n"); varname2.Append(" CreatedUser, \n"); varname2.Append(" CreatedMachine, \n"); varname2.Append(" CreatedDateTime, \n"); varname2.Append(" ModifiedUser, \n"); varname2.Append(" ModifiedMachine, \n"); varname2.Append(" ModifiedDateTime) \n"); varname2.Append("VALUES (?UserName, \n"); varname2.Append(" ?Password, \n"); varname2.Append(" ?UserType, \n"); varname2.Append(" ?LoginAttempts, \n"); varname2.Append(" ?CreatedUser, \n"); varname2.Append(" ?CreatedMachine, \n"); varname2.Append(" ?CreatedDateTime, \n"); varname2.Append(" ?ModifiedUser, \n"); varname2.Append(" ?ModifiedMachine, \n"); varname2.Append(" ?ModifiedDateTime)"); oUniversalConnection.CommandText = varname2.ToString(); oUniversalConnection.Parameters.Clear(); oUniversalConnection.Parameters.Add(new Parameter { Name = "UserName", Value = (object)oLoginDTOs.UserName ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "Password", Value = (object)oLoginDTOs.Password ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "UserType", Value = (object)oLoginDTOs.UserType ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "LoginAttempts", Value = (object)oLoginDTOs.LoginAttempts ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "CreatedUser", Value = (object)oLoginDTOs.CreatedUser ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "CreatedMachine", Value = (object)oLoginDTOs.CreatedMachine ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "CreatedDateTime", Value = (object)oLoginDTOs.CreatedDateTime ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedUser", Value = (object)oLoginDTOs.ModifiedUser ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedMachine", Value = (object)oLoginDTOs.ModifiedMachine ?? DBNull.Value }); oUniversalConnection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = (object)oLoginDTOs.ModifiedDateTime ?? DBNull.Value }); resultCount = oUniversalConnection.ExecuteQuery(); return(resultCount > 0); } } catch (Exception ex) { Logger.Write(ex); throw ex; } }
public bool UpdateCompanyData(CompanyMaintanance oCompanyMaintanance) { return(oCompanyBL.CompanyUpdate(oCompanyMaintanance)); }
public bool InsertCompanyData(CompanyMaintanance oCompanyMaintanance) { return(oCompanyBL.CompanyInsert(oCompanyMaintanance)); }
private void UpdateCompanyData() { bool result = false; try { CompanyDTO oCompanyDTOs = new CompanyDTO(); oCompanyDTOs.CompanyId = Convert.ToInt32(Session["CompanyId"].ToString()); oCompanyDTOs.Name = txtName.Text; oCompanyDTOs.Address = txtAddress.Text; oCompanyDTOs.Telephone = txtTelephone.Text; oCompanyDTOs.Email = txtEmail.Text; oCompanyDTOs.Description = txtDescription.InnerText; oCompanyDTOs.Type = Convert.ToInt32(ddlType.SelectedValue.ToString()); oCompanyDTOs.NumberOfShares = Convert.ToInt32(txtNoOfShares.Text); oCompanyDTOs.SharePrice = Convert.ToDecimal(txtSharePrice.Text); oCompanyDTOs.Status = Convert.ToInt32(ddlStatus.SelectedValue.ToString()); oCompanyDTOs.UserName = txtUserName.Text; string EncryptedPwd = Cryptography.Encryption.Encrypt(txtPassword.Text, txtUserName.Text); oCompanyDTOs.Password = EncryptedPwd; oCompanyDTOs.ModifiedUser = Session["UserID"].ToString(); oCompanyDTOs.ModifiedDateTime = DateTime.Now; oCompanyDTOs.ModifiedMachine = Session["UserMachine"].ToString(); #region Login LoginDTO oLoginDTOs = new LoginDTO(); oLoginDTOs.UserName = txtUserName.Text; oLoginDTOs.Password = EncryptedPwd; oLoginDTOs.UserType = Convert.ToInt32(Session["UserType"].ToString()); oLoginDTOs.LoginAttempts = 1; oLoginDTOs.ModifiedUser = Session["UserID"].ToString(); oLoginDTOs.ModifiedDateTime = DateTime.Now; oLoginDTOs.ModifiedMachine = Session["UserMachine"].ToString(); #endregion Login CompanyMaintanance oCompanyMaintanance = new CompanyMaintanance(); oCompanyMaintanance.oCompanyDTO = oCompanyDTOs; oCompanyMaintanance.oLoginDTO = oLoginDTOs; result = oWebApiCalls.UpdateCompanyData(oCompanyMaintanance); if (result == true) { ResetControllers(); Messages("Company Updated Successfully!!"); } else { Messages("Connection Error!"); } } catch (Exception ex) { throw ex; } }
protected void btnCompanyAdd_Click(object sender, EventArgs e) { bool result = false; try { #region Company CompanyDTO oCompanyDTOs = new CompanyDTO(); oCompanyDTOs.Name = txtName.Text; oCompanyDTOs.Address = txtAddress.Text; oCompanyDTOs.Telephone = txtTelephone.Text; oCompanyDTOs.Email = txtEmail.Text; oCompanyDTOs.Description = txtDescription.InnerText; oCompanyDTOs.Type = Convert.ToInt32(ddlType.SelectedValue.ToString()); oCompanyDTOs.NumberOfShares = Convert.ToInt32(txtNoOfShares.Text); oCompanyDTOs.SharePrice = Convert.ToDecimal(txtSharePrice.Text); oCompanyDTOs.Status = Convert.ToInt32(ddlStatus.SelectedValue.ToString()); oCompanyDTOs.UserName = txtUserName.Text; string EncryptedPwd = Cryptography.Encryption.Encrypt(txtPassword.Text, txtUserName.Text); oCompanyDTOs.Password = EncryptedPwd; oCompanyDTOs.CreatedUser = txtName.Text; oCompanyDTOs.CreatedDateTime = DateTime.Now; oCompanyDTOs.CreatedMachine = Request.ServerVariables["REMOTE_ADDR"].ToString(); oCompanyDTOs.ModifiedUser = txtName.Text; oCompanyDTOs.ModifiedDateTime = DateTime.Now; oCompanyDTOs.ModifiedMachine = Request.ServerVariables["REMOTE_ADDR"].ToString(); #endregion #region Login LoginDTO oLoginDTOs = new LoginDTO(); oLoginDTOs.UserName = txtUserName.Text; oLoginDTOs.Password = EncryptedPwd; oLoginDTOs.UserType = Convert.ToInt32(ddlUserType.SelectedValue.ToString()); oLoginDTOs.LoginAttempts = 1; oLoginDTOs.CreatedUser = txtName.Text; oLoginDTOs.CreatedDateTime = DateTime.Now; oLoginDTOs.CreatedMachine = Request.ServerVariables["REMOTE_ADDR"].ToString(); oLoginDTOs.ModifiedUser = txtName.Text; oLoginDTOs.ModifiedDateTime = DateTime.Now; oLoginDTOs.ModifiedMachine = Request.ServerVariables["REMOTE_ADDR"].ToString(); #endregion CompanyMaintanance oCompanyMaintanance = new CompanyMaintanance(); oCompanyMaintanance.oCompanyDTO = oCompanyDTOs; oCompanyMaintanance.oLoginDTO = oLoginDTOs; result = oWebApiCalls.InsertCompanyData(oCompanyMaintanance); if (result == true) { Messages("Company Inserted Successfully!!"); ResetControllers(); Response.Redirect("~/Login.aspx"); } else { Messages("Connection Error!"); } } catch (Exception ex) { throw ex; } }