protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            try
            {
                string retvalstr = "";

                if (ValidatePage() == true)
                {
                    AdminViewModel _adminViewModel = new AdminViewModel();
                    AdminModel _AdminModel = new AdminModel();

                    _AdminModel.UserType = ddUserType.Text;
                    _AdminModel.AdminFullName = txtFullName.Value;
                    _AdminModel.AdminMobNo = txtMobileNo.Value;
                    _AdminModel.VenueID = ddVenueDetails.SelectedValue;
                    _AdminModel.AdminUserName = txtUserName.Value;
                    _AdminModel.AdminEmailID = txtEmailID.Value;

                    //SendEmailProcess _sendProcess = new SendEmailProcess();
                    //string body = string.Empty;

                    //using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailFormat.html")))
                    //{
                    //    body = reader.ReadToEnd();
                    //}

                    //string retval ="" ;
                    //string retvalEx = _sendProcess.SendEmail(txtEmailID.Value, body, out retval);

                    string pwd = GenerateRandomCode();
                    _AdminModel.AdminUserPassword = pwd;

                    retvalstr = _adminViewModel.InsertAdminDetails(_AdminModel);

                    if (retvalstr.Contains("Email ID"))
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "javascript:alert('Email ID already Registered.');", true);
                    }
                    else if (retvalstr.Contains("User Added"))
                    {
                        bool retval = SendEmail(txtEmailID.Value, pwd);

                        if (retval == false)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "javascript:alert('Unexpected error occured.Plese refresh the page and try again!');", true);

                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "javascript:alert('Data saved sucessfully');", true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message);
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "javascript:alert('Server is busy.Please try after sometime.');", true);
            }
        }
        protected void btnUpdate_ServerClick(object sender, EventArgs e)
        {
            try
            {
                if (ValidatePage() == true)
                {
                    AdminViewModel _adminViewModel = new AdminViewModel();
                    AdminModel _AdminModel = new AdminModel();

                    _AdminModel.AdminUserID = Convert.ToInt32(hdAdminID.Value);
                    _AdminModel.UserType = ddUserType.Text;
                    _AdminModel.AdminFullName = txtFullName.Value;
                    _AdminModel.AdminMobNo = txtMobileNo.Value;
                    _AdminModel.VenueID = ddVenueDetails.SelectedValue;
                    _AdminModel.AdminUserName = txtUserName.Value;
                    _AdminModel.AdminEmailID = txtEmailID.Value;

                    bool retval;
                    retval = _adminViewModel.UpdateAdminDetails(_AdminModel);

                    if (retval == true)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Add User", "<script type='text/javascript'>ConfirmMsg('Data saved sucessfully.','Add User');</script>", false);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Add User", "<script type='text/javascript'>ConfirmMsg('Unexpected error occured.Plese refresh the page and try again!','Add User');</script>", false);
                    }

                    //Response.Redirect("/AdminList.aspx");//-kk redirect
                            Response.Redirect("/AdminList.aspx", false);
                            Context.ApplicationInstance.CompleteRequest();

                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message);
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "javascript:alert('Server is busy.Please try after sometime.');", true);
            }
        }
 private void GetAdminDetailsByID(int ID)
 {
     try
     {
         AdminViewModel _adminViewModel = new AdminViewModel();
         AdminModel _adminModel = new AdminModel();
         _adminModel = _adminViewModel.GetAdminDetails(ID);
         txtFullName.Value = _adminModel.AdminFullName;
         txtMobileNo.Value = _adminModel.AdminMobNo;
         ddVenueDetails.SelectedValue = _adminModel.VenueID;
         txtUserName.Value = _adminModel.AdminUserName;
         txtEmailID.Value = _adminModel.AdminEmailID;
         ddUserType.SelectedValue = _adminModel.UserType;
     }
     catch (Exception ex)
     {
         ErrHandler.WriteError(ex.Message);
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "javascript:alert('Server is busy.Please try after sometime.');", true);
     }
 }
Beispiel #4
0
        ////update
        public bool UpdateAdminDetails(AdminModel adminModel)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnString))
                {
                    using (SqlCommand cmd = new SqlCommand("SL_PROC_UPDATEADMINDETAILS", conn))
                    {
                        conn.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@AdminUserID", SqlDbType.Int).Value = adminModel.AdminUserID;
                        cmd.Parameters.Add("@AdminUserName", SqlDbType.VarChar, 50).Value = adminModel.AdminUserName;
                        cmd.Parameters.Add("@AdminFullName", SqlDbType.VarChar, 100).Value = adminModel.AdminFullName;
                        cmd.Parameters.Add("@AdminMobNo", SqlDbType.VarChar, 20).Value = adminModel.AdminMobNo;
                        cmd.Parameters.Add("@VenueID", SqlDbType.Int).Value = adminModel.VenueID;
                        cmd.Parameters.Add("@AdminEmailID", SqlDbType.VarChar, 100).Value = adminModel.AdminEmailID;
                        cmd.Parameters.Add("@UserType", SqlDbType.VarChar, 10).Value = adminModel.UserType;

                        cmd.ExecuteNonQuery();
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message);
                return false;
            }
        }
Beispiel #5
0
        //insert
        public string InsertAdminDetails(AdminModel adminModel)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnString))
                {
                    conn.Open();
                    //cmd.CommandText = "SELECT name FROM server WHERE code = @code";
                    //cmd.Parameters.AddWithValue("@code", TextBox1.Text);

                    using (SqlCommand cmdAuth = new SqlCommand("SELECT Count(*) FROM AdminUser where AdminEmailID= @USERID", conn))
                    {
                        cmdAuth.Parameters.AddWithValue("@USERID",adminModel.AdminEmailID);
                        object retval = cmdAuth.ExecuteScalar();

                        if (Convert.ToInt32(retval) >= 1)
                        {
                            return "Email ID already exits.";
                        }
                        else
                        {
                            using (SqlCommand cmd = new SqlCommand("SL_PROC_INSERTADMINDETAILS", conn))
                            {

                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Add("@AdminUserID", SqlDbType.Int).Value = adminModel.AdminUserID;
                                cmd.Parameters.Add("@AdminUserName", SqlDbType.VarChar, 50).Value = adminModel.AdminUserName;
                                cmd.Parameters.Add("@AdminFullName", SqlDbType.VarChar, 100).Value = adminModel.AdminFullName;
                                cmd.Parameters.Add("@AdminMobNo", SqlDbType.VarChar, 20).Value = adminModel.AdminMobNo;
                                cmd.Parameters.Add("@AdminUserPassword", SqlDbType.VarChar, 50).Value = adminModel.AdminUserPassword;
                                cmd.Parameters.Add("@VenueID", SqlDbType.Int).Value = adminModel.VenueID;
                                cmd.Parameters.Add("@AdminEmailID", SqlDbType.VarChar, 100).Value = adminModel.AdminEmailID;
                                cmd.Parameters.Add("@UserType", SqlDbType.VarChar, 10).Value = adminModel.UserType;

                                cmd.ExecuteNonQuery();
                                return "User Added sucessfully.";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message);
                throw ex;
            }
        }
Beispiel #6
0
        public AdminModel GetAdminDetails(int AdminID)
        {
            AdminModel _adminModel = new AdminModel();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnString))
                {
                    using (SqlCommand cmd = new SqlCommand("SL_PROC_GETADMINDETAILS_BYID", conn))
                    {
                        conn.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@ADMINID", SqlDbType.Int).Value = AdminID;

                        SqlDataReader dr = cmd.ExecuteReader();

                        while (dr.Read())
                        {
                               _adminModel.AdminUserID = Convert.ToInt32(dr["AdminUserID"]);
                               _adminModel.AdminUserName = dr["AdminUserName"].ToString();
                               _adminModel.AdminFullName = dr["AdminFullName"].ToString();
                               _adminModel.AdminMobNo = dr["AdminMobNo"].ToString();
                               _adminModel.VenueID = dr["VenueID"].ToString();
                               _adminModel.AdminEmailID = dr["AdminEmailID"].ToString();
                               _adminModel.UserType = dr["UserType"].ToString();
                              // _adminModel.VenueName = dr["VenueName"].ToString();

                        }
                    }
                }

                return _adminModel;
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message);
                return null;
            }
        }