Esempio n. 1
0
        private void ViewBrokerData()
        {
            try
            {
                LoadDropDownList();
                GridViewRow oGridViewRow = gvBroker.Rows[Convert.ToInt32(ViewState["index"])];
                Label       lblBrokerId  = (Label)oGridViewRow.FindControl("lblBrokerId");
                Session["BrokerId"] = lblBrokerId.Text;
                BrokerDTO oBrokerDTO = new BrokerDTO();
                oBrokerDTO = oWebApiCalls.BrokerSearchById(Convert.ToInt32(lblBrokerId.Text));

                txtName.Text             = oBrokerDTO.Name;
                txtAddress.Text          = oBrokerDTO.Address;
                txtTelephone.Text        = oBrokerDTO.Telephone;
                txtEmail.Text            = oBrokerDTO.Email;
                txtDescription.InnerText = oBrokerDTO.Description;
                ddlType.SelectedValue    = Convert.ToString((int)oBrokerDTO.Type);
                txtJoinDate.Text         = oBrokerDTO.JoinDate.ToString("yyyy-MM-dd");
                //txtNoOfShares.Text = Convert.ToString(oBrokerDTO.NumberOfShares);
                //txtSharePrice.Text = Convert.ToString(oBrokerDTO.SharePrice);
                ddlStatus.SelectedValue = Convert.ToString((int)oBrokerDTO.Status);

                string DecryptedPwd = Cryptography.Encryption.Decrypt(oBrokerDTO.Password, oBrokerDTO.UserName);

                txtUserName.Text = oBrokerDTO.UserName;
                txtPassword.Text = DecryptedPwd;

                ControllersHandler(CommandMood.View);
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
                throw ex;
            }
        }
Esempio n. 2
0
        private void DeleteBrokerData()
        {
            bool result = false;

            try
            {
                GridViewRow oGridViewRow = gvBroker.Rows[Convert.ToInt32(ViewState["index"])];
                Label       lblBrokerId  = (Label)oGridViewRow.FindControl("lblBrokerId");
                BrokerDTO   oBrokerDTO   = new BrokerDTO();

                oBrokerDTO.BrokerId         = Convert.ToInt32(lblBrokerId.Text);
                oBrokerDTO.Status           = (int)Status.Inactive;
                oBrokerDTO.ModifiedUser     = Session["UserID"].ToString();
                oBrokerDTO.ModifiedDateTime = DateTime.Now;
                oBrokerDTO.ModifiedMachine  = Session["UserMachine"].ToString();

                result = oWebApiCalls.DeleteBrokerData(oBrokerDTO);

                if (result == true)
                {
                    ResetControllers();
                    Messages("Broker Deleted Successfully!!");
                }
                else
                {
                    Messages("Connection Error!");
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
                throw ex;
            }
        }
Esempio n. 3
0
        public bool DeleteBrokerData(BrokerDTO oBrokerDTO)
        {
            bool ReturnValue = false;

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    string path = "Broker/DeleteBrokerData";
                    client.BaseAddress = new Uri(GlobalValues.BaseUri);
                    var json    = JsonConvert.SerializeObject(oBrokerDTO);
                    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);
        }
Esempio n. 4
0
        public BrokerDTO BrokerSearchById(int BrokerId)
        {
            BrokerDTO oBrokerDTO = new BrokerDTO();

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    string path = "Broker/BrokerSearchById?BrokerId=" + BrokerId;
                    client.BaseAddress = new Uri(GlobalValues.BaseUri);

                    HttpResponseMessage responce = client.GetAsync(path).Result;
                    if (responce.IsSuccessStatusCode)
                    {
                        var value = responce.Content.ReadAsStringAsync().Result;
                        oBrokerDTO = JsonConvert.DeserializeObject <BrokerDTO>(value);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(oBrokerDTO);
        }
 /// <summary>
 /// Method that compares the values from the properties to check if they are the same
 /// </summary>
 /// <param name="broker1">Broker entity</param>
 /// <param name="broker2">Broker entity</param>
 /// <returns>True if the values are the same, false otherwise</returns>
 private bool CompareBrokerDTO(BrokerDTO broker1, BrokerDTO broker2)
 {
     return(broker1.Id == broker2.Id &&
            broker1.Email == broker2.Email &&
            broker1.ImageUrl == broker2.ImageUrl &&
            broker1.MobilePhoneNumber == broker2.MobilePhoneNumber &&
            broker1.Name == broker2.Name &&
            broker1.OfficePhoneNumber == broker2.OfficePhoneNumber &&
            broker1.Position == broker2.Position);
 }
 public bool DeleteBrokerData(BrokerDTO oBrokerDTO)
 {
     return(oBrokerBL.BrokerDelete(oBrokerDTO));
 }
Esempio n. 7
0
        public bool BrokerInsert(BrokerMaintanance oBrokerMaintanance)
        {
            BrokerDTO oBrokerDTOs = oBrokerMaintanance.oBrokerDTO;
            LoginDTO  oLoginDTOs  = oBrokerMaintanance.oLoginDTO;

            int resultCount = 0;

            try
            {
                using (UniversalConnection oUniversalConnection = new UniversalConnection(Connection.Common.ConnectionString))
                {
                    StringBuilder varname1 = new StringBuilder();
                    varname1.Append("INSERT INTO Broker \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("             JoinDate, \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("             ?JoinDate, \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)oBrokerDTOs.Name ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Address", Value = (object)oBrokerDTOs.Address ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Telephone", Value = (object)oBrokerDTOs.Telephone ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Email", Value = (object)oBrokerDTOs.Email ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Description", Value = (object)oBrokerDTOs.Description ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Type", Value = (object)oBrokerDTOs.Type ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "JoinDate", Value = (object)oBrokerDTOs.JoinDate ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Status", Value = (object)oBrokerDTOs.Status ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "UserName", Value = (object)oBrokerDTOs.UserName ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Password", Value = (object)oBrokerDTOs.Password ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "CreatedUser", Value = (object)oBrokerDTOs.CreatedUser ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "CreatedMachine", Value = (object)oBrokerDTOs.CreatedMachine ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "CreatedDateTime", Value = (object)oBrokerDTOs.CreatedDateTime ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "ModifiedUser", Value = (object)oBrokerDTOs.ModifiedUser ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "ModifiedMachine", Value = (object)oBrokerDTOs.ModifiedMachine ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "ModifiedDateTime", Value = (object)oBrokerDTOs.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;
            }
        }
Esempio n. 8
0
        public BrokerDTO BrokerSearchById(int BrokerId)
        {
            BrokerDTO result = new BrokerDTO();

            try
            {
                using (UniversalConnection oUniversalConnection = new UniversalConnection(Connection.Common.ConnectionString))
                {
                    StringBuilder varname1 = new StringBuilder();
                    varname1.Append("SELECT [BrokerId], \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("       [JoinDate], \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("FROM   [dbo].[Broker] \n");
                    varname1.Append("WHERE  [Status] = ?Status");
                    varname1.Append(" AND  [BrokerId] = ?BrokerId");
                    oUniversalConnection.CommandText = varname1.ToString();
                    oUniversalConnection.Parameters.Clear();
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Status", Value = Status.Active
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "BrokerId", Value = BrokerId
                    });

                    using (IDataReader dr = oUniversalConnection.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            result.BrokerId         = Helper.GetDataValue <int>(dr, "BrokerId");
                            result.Name             = Helper.GetDataValue <string>(dr, "Name");
                            result.Address          = Helper.GetDataValue <string>(dr, "Address");
                            result.Telephone        = Helper.GetDataValue <string>(dr, "Telephone");
                            result.Email            = Helper.GetDataValue <string>(dr, "Email");
                            result.Description      = Helper.GetDataValue <string>(dr, "Description");
                            result.Type             = Helper.GetDataValue <int>(dr, "Type");
                            result.JoinDate         = Helper.GetDataValue <DateTime>(dr, "JoinDate");
                            result.Status           = Helper.GetDataValue <int>(dr, "Status");
                            result.UserName         = Helper.GetDataValue <string>(dr, "UserName");
                            result.Password         = Helper.GetDataValue <string>(dr, "Password");
                            result.CreatedUser      = Helper.GetDataValue <string>(dr, "CreatedUser");
                            result.CreatedMachine   = Helper.GetDataValue <string>(dr, "CreatedMachine");
                            result.CreatedDateTime  = Helper.GetDataValue <DateTime>(dr, "CreatedDateTime");
                            result.ModifiedUser     = Helper.GetDataValue <string>(dr, "ModifiedUser");
                            result.ModifiedMachine  = Helper.GetDataValue <string>(dr, "ModifiedMachine");
                            result.ModifiedDateTime = Helper.GetDataValue <DateTime>(dr, "ModifiedDateTime");
                        }
                        dr.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                throw ex;
            }

            return(result);
        }
Esempio n. 9
0
        public bool BrokerUpdate(BrokerMaintanance oBrokerMaintanance)
        {
            BrokerDTO oBrokerDTOs = oBrokerMaintanance.oBrokerDTO;
            LoginDTO  oLoginDTOs  = oBrokerMaintanance.oLoginDTO;

            int resultCount = 0;

            try
            {
                using (UniversalConnection oUniversalConnection = new UniversalConnection(Connection.Common.ConnectionString))
                {
                    oUniversalConnection.Parameters.Clear();

                    StringBuilder varname1 = new StringBuilder();
                    varname1.Append("UPDATE Broker \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("     JoinDate = ?JoinDate, \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  BrokerId = ?BrokerId");

                    oUniversalConnection.CommandText = varname1.ToString();
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "BrokerId", Value = (object)oBrokerDTOs.BrokerId ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Name", Value = (object)oBrokerDTOs.Name ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Address", Value = (object)oBrokerDTOs.Address ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Telephone", Value = (object)oBrokerDTOs.Telephone ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Email", Value = (object)oBrokerDTOs.Email ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Description", Value = (object)oBrokerDTOs.Description ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Type", Value = (object)oBrokerDTOs.Type ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "JoinDate", Value = (object)oBrokerDTOs.JoinDate ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Status", Value = (object)oBrokerDTOs.Status ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "UserName", Value = (object)oBrokerDTOs.UserName ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "Password", Value = (object)oBrokerDTOs.Password ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "ModifiedUser", Value = (object)oBrokerDTOs.ModifiedUser ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "ModifiedMachine", Value = (object)oBrokerDTOs.ModifiedMachine ?? DBNull.Value
                    });
                    oUniversalConnection.Parameters.Add(new Parameter {
                        Name = "ModifiedDateTime", Value = (object)oBrokerDTOs.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;
            }
        }
Esempio n. 10
0
        private void UpdateBrokerData()
        {
            bool result = false;

            try
            {
                #region Broker
                BrokerDTO oBrokerDTO = new BrokerDTO();
                oBrokerDTO.BrokerId    = Convert.ToInt32(Session["BrokerId"].ToString());
                oBrokerDTO.Name        = txtName.Text;
                oBrokerDTO.Address     = txtAddress.Text;
                oBrokerDTO.Telephone   = txtTelephone.Text;
                oBrokerDTO.Email       = txtEmail.Text;
                oBrokerDTO.Description = txtDescription.InnerText;
                oBrokerDTO.Type        = Convert.ToInt32(ddlType.SelectedValue.ToString());
                oBrokerDTO.JoinDate    = Convert.ToDateTime(txtJoinDate.Text);
                //oBrokerDTO.NumberOfShares = Convert.ToInt32(txtNoOfShares.Text);
                //oBrokerDTO.SharePrice = Convert.ToDecimal(txtSharePrice.Text);
                oBrokerDTO.Status   = Convert.ToInt32(ddlStatus.SelectedValue.ToString());
                oBrokerDTO.UserName = txtUserName.Text;

                string EncryptedPwd = Cryptography.Encryption.Encrypt(txtPassword.Text, txtUserName.Text);

                oBrokerDTO.Password         = EncryptedPwd;
                oBrokerDTO.ModifiedUser     = Session["UserID"].ToString();
                oBrokerDTO.ModifiedDateTime = DateTime.Now;
                oBrokerDTO.ModifiedMachine  = Session["UserMachine"].ToString();
                #endregion

                #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

                BrokerMaintanance oBrokerMaintanance = new BrokerMaintanance();
                oBrokerMaintanance.oBrokerDTO = oBrokerDTO;
                oBrokerMaintanance.oLoginDTO  = oLoginDTOs;

                result = oWebApiCalls.UpdateBrokerData(oBrokerMaintanance);

                if (result == true)
                {
                    ResetControllers();
                    Messages("Broker Updated Successfully!!");
                }
                else
                {
                    Messages("Connection Error!");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        protected void btnBrokerAdd_Click(object sender, EventArgs e)
        {
            bool result = false;

            try
            {
                #region Broker
                BrokerDTO oBrokerDTOs = new BrokerDTO();

                oBrokerDTOs.Name        = txtBName.Text;
                oBrokerDTOs.Address     = txtBAddress.Text;
                oBrokerDTOs.Telephone   = txtBTelephone.Text;
                oBrokerDTOs.Email       = txtBEmail.Text;
                oBrokerDTOs.Description = txtBDescription.InnerText;
                oBrokerDTOs.Type        = Convert.ToInt32(ddlBType.SelectedValue.ToString());
                oBrokerDTOs.JoinDate    = Convert.ToDateTime(dtpBJoinDate.Text);
                oBrokerDTOs.Status      = Convert.ToInt32(ddlBStatus.SelectedValue.ToString());
                oBrokerDTOs.UserName    = txtBUserName.Text;

                string EncryptedPwd = Cryptography.Encryption.Encrypt(txtBPassword.Text, txtBUserName.Text);

                oBrokerDTOs.Password         = EncryptedPwd;
                oBrokerDTOs.CreatedUser      = Session["UserID"].ToString();
                oBrokerDTOs.CreatedDateTime  = DateTime.Now;
                oBrokerDTOs.CreatedMachine   = Session["UserMachine"].ToString();
                oBrokerDTOs.ModifiedUser     = Session["UserID"].ToString();
                oBrokerDTOs.ModifiedDateTime = DateTime.Now;
                oBrokerDTOs.ModifiedMachine  = Session["UserMachine"].ToString();
                #endregion

                #region Login

                LoginDTO oLoginDTOs = new LoginDTO();

                oLoginDTOs.UserName         = txtBUserName.Text;
                oLoginDTOs.Password         = EncryptedPwd;
                oLoginDTOs.UserType         = Convert.ToInt32(Session["UserType"].ToString());
                oLoginDTOs.LoginAttempts    = 1;
                oLoginDTOs.CreatedUser      = Session["UserID"].ToString();
                oLoginDTOs.CreatedDateTime  = DateTime.Now;
                oLoginDTOs.CreatedMachine   = Session["UserMachine"].ToString();
                oLoginDTOs.ModifiedUser     = Session["UserID"].ToString();
                oLoginDTOs.ModifiedDateTime = DateTime.Now;
                oLoginDTOs.ModifiedMachine  = Session["UserMachine"].ToString();

                #endregion

                BrokerMaintanance oBrokerMaintanance = new BrokerMaintanance();
                oBrokerMaintanance.oBrokerDTO = oBrokerDTOs;
                oBrokerMaintanance.oLoginDTO  = oLoginDTOs;

                result = oWebApiCalls.InsertBrokerData(oBrokerMaintanance);

                if (result == true)
                {
                    ResetControllers();
                    Messages("Broker Inserted Successfully!!");
                }
                else
                {
                    Messages("Connection Error!");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }