Esempio n. 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region Server Side Validation
        String strError = "";

        if (txtDepartmentName.Text.Trim() == "")
        {
            strError += "Enter Department +</br>";
        }

        if (strError.Trim() != "")
        {
            PanelErrorMesseage.Visible = true;
            lblErrorMessage.Text       = strError;
            return;
        }
        #endregion Server Side Validation

        #region Collect Data
        DepartmentENT entDepartment = new DepartmentENT();

        if (txtDepartmentName.Text.Trim() != "")
        {
            entDepartment.DepartmentName = txtDepartmentName.Text.Trim();
        }

        #endregion Collect Data

        DepartmentBAL balDepartment = new DepartmentBAL();

        if (Request.QueryString["DepartmentID"] == null)
        {
            if (balDepartment.Insert(entDepartment))
            {
                clearSelection();
                PanelSuccess.Visible = true;
                lblSuccess.Text      = "Data Inserted Successfully";
            }
            else
            {
                PanelErrorMesseage.Visible = true;
                lblErrorMessage.Text       = balDepartment.Message;
            }
        }
        else
        {
            entDepartment.DepartmentID = Convert.ToInt32(Request.QueryString["DepartmentID"].ToString().Trim());

            if (balDepartment.Update(entDepartment))
            {
                Response.Redirect("~/Content/Department/DepartmentList.aspx");
            }
            else
            {
                PanelErrorMesseage.Visible = true;
                lblErrorMessage.Text       = balDepartment.Message;
            }
        }
    }
Esempio n. 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region server side validation
        String strErrorMessage = "";

        if (txtDepartment.Text.Trim() == "")
        {
            strErrorMessage += "- Enter Department <br/>";
        }
        if (strErrorMessage.Trim() != "")
        {
            lblErrorMessage.Text = strErrorMessage;
            return;
        }
        #endregion server side validation

        #region Collect Form Data
        DepartmentENT entDepartment = new DepartmentENT();

        if (txtDepartment.Text.Trim() != "")
        {
            entDepartment.DepartmentName = txtDepartment.Text.Trim();
        }
        #endregion Collect Form Data

        DepartmentBAL balDepartment = new DepartmentBAL();

        if (Convert.ToBoolean(ViewState["DepartmentEditActive"]) == false)
        {
            if (balDepartment.Insert(entDepartment))
            {
                fillDepartmentGridview();
                ClientScript.RegisterStartupScript(GetType(), "SweetAlert", "swal({ type: 'success', title: 'Department Inserted Successfully', showConfirmButton: false, timer: 2000});", true);
                ClearControls();
            }
            else
            {
                lblErrorMessage.Text = balDepartment.Message;
            }
        }
        else
        {
            entDepartment.DepartmentID = Convert.ToInt32(ViewState["DepartmentID"]);
            if (balDepartment.Update(entDepartment))
            {
                fillDepartmentGridview();
                ClientScript.RegisterStartupScript(GetType(), "SweetAlert", "swal({ type: 'success', title: 'Department Edited Successfully', showConfirmButton: false, timer: 2000});", true);
                ClearControls();
                ViewState["DepartmentEditActive"] = false;
                lblModalTitle.Text = "Department Add";
            }
            else
            {
                lblErrorMessage.Text = balDepartment.Message;
            }
        }
    }
Esempio n. 3
0
        public DepartmentENT SelectByPK(SqlInt32 DepartmentID)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();
                using (SqlCommand objCmd = objConn.CreateCommand())
                {
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_Department_SelectByPK";
                        objCmd.Parameters.Add("@DepartmentID", SqlDbType.Int).Value = DepartmentID;
                        #endregion Prepare Command

                        #region Read Data and Set Controls
                        DepartmentENT entDepartment = new DepartmentENT();
                        using (SqlDataReader objSDR = objCmd.ExecuteReader())
                        {
                            while (objSDR.Read())
                            {
                                if (!objSDR["DepartmentID"].Equals(DBNull.Value))
                                {
                                    entDepartment.DepartmentID = Convert.ToInt32(objSDR["DepartmentID"]);
                                }

                                if (!objSDR["DepartmentName"].Equals(DBNull.Value))
                                {
                                    entDepartment.DepartmentName = Convert.ToString(objSDR["DepartmentName"]);
                                }
                            }
                        }
                        return(entDepartment);

                        #endregion Read Data and Set Controls
                    }
                    catch (SqlException ex)
                    {
                        Message = ex.Message;
                        return(null);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        return(null);
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                    }
                }
            }
        }
Esempio n. 4
0
    private void FillControls(SqlInt32 DepartmentID)
    {
        DepartmentBAL balDepartment = new DepartmentBAL();
        DepartmentENT entDepartment = new DepartmentENT();

        entDepartment = balDepartment.SelectByPK(DepartmentID);

        if (!entDepartment.DepartmentName.IsNull)
        {
            txtDepartment.Text = entDepartment.DepartmentName.Value.ToString();
        }
    }
Esempio n. 5
0
        public Boolean Update(DepartmentENT entDepartment)
        {
            DepartmentDAL dalDepartment = new DepartmentDAL();

            if (dalDepartment.Update(entDepartment))
            {
                return(true);
            }
            else
            {
                Message = dalDepartment.Message;
                return(false);
            }
        }
        public Boolean Insert(DepartmentENT entDepartment)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();
                using (SqlCommand objCmd = objConn.CreateCommand())
                {
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_Department_Insert";
                        objCmd.Parameters.Add("@DepartmentID", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
                        objCmd.Parameters.Add("@DepartmentName", SqlDbType.VarChar).Value  = entDepartment.DepartmentName;
                        #endregion Prepare Command

                        objCmd.ExecuteNonQuery();

                        if (objCmd.Parameters["@DepartmentID"] != null)
                        {
                            entDepartment.DepartmentID = Convert.ToInt32(objCmd.Parameters["@DepartmentID"].Value);
                        }

                        return(true);
                    }
                    catch (SqlException sqlEx)
                    {
                        Message = sqlEx.InnerException.Message;
                        return(false);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.InnerException.Message;
                        return(false);
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public Boolean Update(DepartmentENT entDepartment)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();
                using (SqlCommand objCmd = objConn.CreateCommand())
                {
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_Department_UpdateByPK";

                        objCmd.Parameters.Add("@DepartmentID", SqlDbType.Int).Value       = entDepartment.DepartmentID;
                        objCmd.Parameters.Add("@DepartmentName", SqlDbType.VarChar).Value = entDepartment.DepartmentName;
                        #endregion Prepare Command

                        objCmd.ExecuteNonQuery();

                        return(true);
                    }
                    catch (SqlException ex)
                    {
                        Message = ex.Message;
                        return(false);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        return(false);
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                    }
                }
            }
        }
Esempio n. 8
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        #region Server Side Validation
        String strErrorMessage = "";

        if (txtUserName.Text.Trim() == "")
        {
            strErrorMessage += "- Enter Username <br/>";
        }

        if (txtPassword.Text.Trim() == "")
        {
            strErrorMessage += "- Enter Password <br/>";
        }

        if (strErrorMessage != "")
        {
            lblErrorMessage.Text = strErrorMessage;
            return;
        }
        else
        {
            lblErrorMessage.Text = "";
        }
        #endregion Server Side Validation

        #region Read Data
        SqlString UserName = SqlString.Null;
        SqlString Password = SqlString.Null;

        if (txtUserName.Text != "")
        {
            UserName = txtUserName.Text.ToString().Trim();
        }

        if (txtPassword.Text != "")
        {
            Password = txtPassword.Text.ToString().Trim();
        }
        #endregion Read Data

        if (Request.QueryString["user"] == "admin" || Convert.ToBoolean(Application["CheckAdmin"]) == true)
        {
            AdminBAL balAdmin = new AdminBAL();
            AdminENT entAdmin = new AdminENT();

            entAdmin = balAdmin.SelectByUserNamePassword(UserName, Password);

            if (!entAdmin.AdminID.IsNull)
            {
                if (!entAdmin.AdminID.IsNull)
                {
                    Session["UserID"] = Convert.ToString(entAdmin.AdminID.Value);
                }

                if (!entAdmin.UserName.IsNull)
                {
                    Session["UserName"] = Convert.ToString(entAdmin.UserName.Value);
                }

                if (!entAdmin.AdminImage.IsNull)
                {
                    Session["UserImage"] = Convert.ToString(entAdmin.AdminImage.Value);
                }

                string ReturnUrl = Convert.ToString(Request.QueryString["url"]);

                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    Response.Redirect(ReturnUrl);
                }
                else
                {
                    Response.Redirect("~/AdminPanel/Dashboard.aspx");
                }
            }
            else
            {
                lblErrorMessage.Text = "Eithe Username or password is Invalid, Try again...!";
            }
        }
        else if (Request.QueryString["user"] == "doctor" || Convert.ToBoolean(Application["CheckDoctor"]) == true)
        {
            DoctorBAL balDoctor = new DoctorBAL();
            DoctorENT entDoctor = new DoctorENT();

            entDoctor = balDoctor.SelectByUserNamePassword(UserName, Password);

            if (!entDoctor.DoctorID.IsNull)
            {
                if (!entDoctor.DoctorID.IsNull)
                {
                    Session["UserID"] = Convert.ToString(entDoctor.DoctorID.Value);
                }

                if (!entDoctor.DoctorName.IsNull)
                {
                    Session["UserName"] = Convert.ToString(entDoctor.DoctorName.Value);
                }

                if (!entDoctor.DoctorImage.IsNull)
                {
                    Session["UserImage"] = Convert.ToString(entDoctor.DoctorImage.Value);
                }

                if (!entDoctor.DepartmentID.IsNull)
                {
                    DepartmentENT entDepartment = new DepartmentENT();
                    DepartmentBAL balDepartment = new DepartmentBAL();

                    entDepartment             = balDepartment.SelectByPK(Convert.ToInt32(entDoctor.DepartmentID.Value));
                    Session["DepartmentName"] = entDepartment.DepartmentName.Value;
                }

                string ReturnUrl = Convert.ToString(Request.QueryString["url"]);

                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    Response.Redirect(ReturnUrl);
                }
                else
                {
                    Response.Redirect("~/AdminPanel/Dashboard.aspx");
                }
            }
            else
            {
                lblErrorMessage.Text = "Eithe Username or password is Invalid, Try again...!";
            }
        }
        else
        {
            Response.Redirect("~/AdminPanel/Authentication/CheckUser.aspx");
        }
    }