Пример #1
0
 /// <summary>
 /// Gets User list by filter criteria.
 /// </summary>
 /// <returns>Returns dataset contains custromer data.</returns>
 public DataSet GetUserSearch(UserMasterBDto objUser)
 {
     Database db = null;
     DbCommand dbCmd = null;
     DataSet ds = null;
     try
     {
         db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING);
         dbCmd = db.GetStoredProcCommand(DALHelper.USP_ADMINISTRATION_USER_DYNAMIC_SELECT);
         db.AddInParameter(dbCmd, "@USER_NAME", DbType.String, objUser.UserName);
         ds = db.ExecuteDataSet(dbCmd);
     }
     catch (Exception ex)
     {
         bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
         if (rethrow)
         {
             throw ex;
         }
     }
     finally
     {
         DALHelper.Destroy(ref dbCmd);
     }
     return ds;
 }
Пример #2
0
        /// <summary>
        /// Update User detail.
        /// </summary>
        /// <param name="xmlData">Data that converted into xml format.</param>
        /// <returns>Returns 1 and 0; (1 indicates successful operation).</returns>
        public int UpdateUser(UserMasterBDto objUser)
        {
            Database db = null;
            DbCommand dbCmd = null;
            int Result = 0;
            try
            {
                db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING);
                dbCmd = db.GetStoredProcCommand(DALHelper.USP_ADMINISTRATION_USER_UPDATE);
                db.AddInParameter(dbCmd, "@USER_ID", DbType.Int32, objUser.m_UserId);
                db.AddInParameter(dbCmd, "@USER_NAME", DbType.String, objUser.UserName);
                db.AddInParameter(dbCmd, "@PASSWORD", DbType.String, objUser.Password);
                db.AddInParameter(dbCmd, "@EMP_ID", DbType.Int32, objUser.EmpID);
                db.AddInParameter(dbCmd, "@SECURITY_QUESTION_ID", DbType.Int32, objUser.SecurityQusId);
                db.AddInParameter(dbCmd, "@SECURITY_ANSWERS", DbType.String, objUser.SecurityQusAns);
                db.AddInParameter(dbCmd, "@FROM_DATE", DbType.DateTime, objUser.FromDate);

                if (objUser.ToDate == DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@TO_DATE", DbType.DateTime, DBNull.Value);
                else
                    db.AddInParameter(dbCmd, "@TO_DATE", DbType.DateTime, objUser.ToDate);

                //db.AddInParameter(dbCmd, "@TO_DATE", DbType.DateTime, objUser.ToDate);
                db.AddInParameter(dbCmd, "@MODIFIED_BY", DbType.Int32, objUser.UserId);
                db.AddOutParameter(dbCmd, "@IS_INSERT", DbType.Int32, 1);
                db.ExecuteNonQuery(dbCmd);
                Result = Convert.ToInt32(db.GetParameterValue(dbCmd, "@IS_INSERT"));
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                {
                    throw ex;
                }
            }
            finally
            {
                DALHelper.Destroy(ref dbCmd);
            }
            return Result;
        }
Пример #3
0
        /// <summary>
        /// Action bar's Search button event which search records from database. 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void acbUser_SearchClick(object sender, EventArgs e)
        {
            #region OpenSearchInNewForm
            //acbUser.Visible = false;
            //pnlGrid.Visible = false;
            //ucControlBox.SaveButton.CommandName = "Search";
            //ucControlBox.SaveButton.Text = "Search";
            //ValidationGroupSearch();
            //txtPassword.Enabled = false;
            //txtRetypePassword.Enabled = false;
            //pnlAddMode.Visible = true;

            //radMultiPage.SelectedIndex = 0;
            //radTabStripe.FindTabByText("User Access").Enabled = false;
            //radTabStripe.FindTabByText("User Info").Selected = true;

            //Reset();
            //BindEmployeeCombo(ddlEmployeeName);
            //BindSecurityQuestionCombo(ddlSecurityQus);
            #endregion
            ////
            UserMasterBDto objUserMasterBDto = new UserMasterBDto();
            UserMasterDal objUserMasterDal = new UserMasterDal();
            objUserMasterBDto.UserName = acbUser.SearchTextBox.Text.Trim();
            DataSet dsUser = objUserMasterDal.GetUserSearch(objUserMasterBDto);
            if (dsUser != null && dsUser.Tables[0].Rows.Count > 0)
            {
                radgrdUser.DataSource = dsUser;
                radgrdUser.DataBind();
                ViewState[vsUser] = dsUser;
            }
            else
            {
                Master.DisplayMessage(ConfigurationSettings.AppSettings["NoRecord"].ToString());
                Master.MessageCssClass = "errorMessage";
            }
        }
Пример #4
0
        /// <summary>
        /// Action bar's save button event which saves grid data by xml.
        /// </summary>
        /// <param name="sender">The object which raised the event</param>
        /// <param name="e">The event listener object</param>
        protected void acbUser_SaveClick(object sender, EventArgs e)
        {
            int result = 0;
            objUserMasterDAL = new UserMasterDal();
            switch (ucControlBox.SaveButton.CommandName)
            {
                case "Save":
                    objUserMasterBdto = new UserMasterBDto();
                    objUserMasterBdto.UserId = objAuthorizationBDto.UserProfile.UserId;
                    objUserMasterBdto.UserName = txtUserName.Text;
                    objUserMasterBdto.Password = txtPassword.Text;
                    objUserMasterBdto.EmpID = int.Parse(ddlEmployeeName.SelectedValue);
                    objUserMasterBdto.SecurityQusId = int.Parse(ddlSecurityQus.SelectedValue);
                    objUserMasterBdto.SecurityQusAns = txtSecurityQusAns.Text;
                    objUserMasterBdto.FromDate = Convert.ToDateTime(rdpFromDate.SelectedDate);
                    objUserMasterBdto.ToDate = Convert.ToDateTime(rdpToDate.SelectedDate);
                    result = objUserMasterDAL.InsertUser(objUserMasterBdto);

                    GlobalUserId = result;
                    GlobalEmpId = int.Parse(ddlEmployeeName.SelectedValue);

                    if (result == -2)
                    {
                        Master.DisplayMessage("Username already exists. Record is not saved.");
                        Master.MessageCssClass = "errorMessage";
                    }
                    else if (result >= 1)
                    {
                        Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Save].ToString());
                        Master.MessageCssClass = "successMessage";
                        BindGrid();
                        radTabStripe.FindTabByText("User Access").Enabled = true;
                        FillCompanyLists(GlobalUserId, GlobalEmpId);
                        BindRoleList();
                    }
                    else
                    {
                        Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Save].ToString());
                        Master.MessageCssClass = "errorMessage";
                    }
                    break;
                case "Update":
                    objUserMasterBdto = new UserMasterBDto();
                    objUserMasterDAL = new UserMasterDal();
                    //UpdateUser();

                    if (ViewState[PageConstants.vsItemIndexes] != null)
                    {
                        htItemIndex = (Hashtable)(ViewState[PageConstants.vsItemIndexes]);
                    }
                    if (htItemIndex != null)
                    {
                        GridDataItem item = radgrdUser.Items[int.Parse(htItemIndex[0].ToString())];
                        //Label lblGrdUserId = (Label)radgrdUser.Items[Convert.ToInt32(htItemIndex[0])].FindControl("lblGrdUserID");
                        objUserMasterBdto.m_UserId = int.Parse(item["USER_ID"].Text);
                        objUserMasterBdto.UserId = objAuthorizationBDto.UserProfile.UserId;
                        objUserMasterBdto.UserName = txtUserName.Text;
                        objUserMasterBdto.Password = txtPassword.Text;
                        objUserMasterBdto.EmpID = int.Parse(ddlEmployeeName.SelectedValue);
                        objUserMasterBdto.SecurityQusId = int.Parse(ddlSecurityQus.SelectedValue);
                        objUserMasterBdto.SecurityQusAns = txtSecurityQusAns.Text;
                        objUserMasterBdto.FromDate = Convert.ToDateTime(rdpFromDate.SelectedDate);
                        objUserMasterBdto.ToDate = Convert.ToDateTime(rdpToDate.SelectedDate);
                        GlobalEmpId = int.Parse(ddlEmployeeName.SelectedValue);
                        result = objUserMasterDAL.UpdateUser(objUserMasterBdto);
                        if (result == 1)
                        {
                            acbUser.DefaultMode = true;
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Update].ToString());
                            Master.MessageCssClass = "successMessage";

                            if (ViewState[PageConstants.vsItemIndexes] != null)
                                htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];
                            for (int i = 0; i < htItemIndex.Count; i++)
                                radgrdUser.Items[Convert.ToInt32(htItemIndex[i])].Edit = false;
                            //bisEdit = true;
                            ViewState[PageConstants.vsItemIndexes] = null;
                            BindGrid();
                            radgrdUser.Rebind();
                            acbUser.Visible = true;
                            pnlAddMode.Visible = false;
                            pnlGrid.Visible = true;
                        }
                        else
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Update].ToString());
                            Master.MessageCssClass = "errorMessage";
                            acbUser.Visible = true;
                            pnlAddMode.Visible = false;
                        }
                    }
                    break;
                case "Search":
                    {
                        //UserMasterBDto objUserMasterBDto = new UserMasterBDto();
                        //objUserMasterBDto.UserName = txtUserName.Text;
                        //objUserMasterBDto.EmpID = int.Parse(ddlEmployeeName.SelectedValue);
                        //objUserMasterBDto.SecurityQusId = int.Parse(ddlSecurityQus.SelectedValue);
                        //objUserMasterBDto.SecurityQusAns = txtSecurityQusAns.Text;
                        //objUserMasterBDto.FromDate = Convert.ToDateTime(rdpFromDate.SelectedDate);
                        //objUserMasterBDto.ToDate = Convert.ToDateTime(rdpToDate.SelectedDate);
                        //DataSet dsUser = objUserMasterDAL.GetUser(objUserMasterBDto);
                        //if (dsUser != null && dsUser.Tables[0].Rows.Count > 0)
                        //{
                        //    radgrdUser.DataSource = dsUser;
                        //    radgrdUser.DataBind();
                        //    ViewState[vsUser] = dsUser;
                        //    acbUser.Visible = true;
                        //    pnlAddMode.Visible = false;
                        //    pnlGrid.Visible = true;
                        //}
                        //else
                        //{
                        //    Master.DisplayMessage(ConfigurationSettings.AppSettings["NoRecord"].ToString());
                        //    Master.MessageCssClass = "errorMessage";
                        //}
                        break;
                    }
            }
        }
Пример #5
0
 private void UpdateUser()
 {
     objUserMasterBdto = new UserMasterBDto();
     try
     {
         if (htItemIndex != null && htItemIndex.Count > 0)
         {
             for (int i = 0; i < htItemIndex.Count; i++)
             {
                 Label lblGrdUserId = (Label)radgrdUser.Items[Convert.ToInt32(htItemIndex[i])].FindControl("lblGrdUserID");
                 objUserMasterBdto.UserId = objAuthorizationBDto.UserProfile.UserId;
                 objUserMasterBdto.UserName = txtUserName.Text;
                 objUserMasterBdto.Password = txtPassword.Text;
                 objUserMasterBdto.EmpID = int.Parse(ddlEmployeeName.SelectedValue);
                 objUserMasterBdto.SecurityQusId = int.Parse(ddlSecurityQus.SelectedValue);
                 objUserMasterBdto.SecurityQusAns = txtSecurityQusAns.Text;
                 objUserMasterBdto.FromDate = Convert.ToDateTime(rdpFromDate.SelectedDate);
                 objUserMasterBdto.ToDate = Convert.ToDateTime(rdpToDate.SelectedDate);
             }
         }
     }
     catch (Exception ex) { }
 }