Beispiel #1
0
    protected void gvDepartment_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "EditRecord")
        {
            if (e.CommandArgument != null)
            {
                ViewState["DepartmentEditActive"] = true;
                ViewState["DepartmentID"]         = Convert.ToInt32(e.CommandArgument.ToString());
                lblModalTitle.Text = "Department Edit";

                FillControls(Convert.ToInt32(e.CommandArgument.ToString()));

                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "departmentAddEditModal();", true);
            }
        }
        if (e.CommandName == "DeleteRecord")
        {
            if (e.CommandArgument != null)
            {
                DepartmentBAL balDepartment = new DepartmentBAL();

                if (balDepartment.Delete(Convert.ToInt32(e.CommandArgument.ToString())))
                {
                    fillDepartmentGridview();
                    ClientScript.RegisterStartupScript(GetType(), "SweetAlert", "swal({ type: 'success', title: 'Department Deleted Successfully', showConfirmButton: false, timer: 2000});", true);
                }
                else
                {
                    lblErrorMessage.Text = balDepartment.Message;
                }
            }
        }
    }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (selectedRecordId != 0)
     {
         try
         {
             Cursor = Cursors.WaitCursor;
             DepartmentBAL _objBAL = new DepartmentBAL();
             _objBAL.DeleteUser(selectedRecordId);
             MessageBox.Show("Record has been deleted successfully!");
             FillGrid();
         }
         catch (System.Data.SqlClient.SqlException sqlEx)
         {
             if (sqlEx.Number == 547)
             {
                 MessageBox.Show("You cannot delete this record. Its refference exists in other documents.");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         finally
         {
             Cursor = Cursors.Default;
             MakeEmpty();
         }
     }
 }
 protected void gvDepartment_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteRecord")
     {
         if (e.CommandArgument != null)
         {
             DepartmentBAL balDepartment = new DepartmentBAL();
             if (balDepartment.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim())))
             {
                 FillGridViewDepartment();
             }
             else
             {
                 PanelErrorMesseage.Visible = true;
                 lblErrorMesseage.Text      = balDepartment.Message;
             }
         }
     }
     else if (e.CommandName == "EditRecord")
     {
         if (e.CommandArgument != null)
         {
             Response.Redirect(e.CommandArgument.ToString().Trim());
         }
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     Cursor = Cursors.WaitCursor;
     try
     {
         if (validate() == true)
         {
             DepartmentBAL   _objBAL   = new DepartmentBAL();
             DepartmentModel _objModel = new DepartmentModel();
             _objModel._DeptID       = selectedRecordId;
             _objModel._DeptName     = tbxDeptName.Text;
             _objModel._Description  = tbxDescription.Text;
             _objModel._ModifiedDate = DateTime.Now;
             _objModel._IsActive     = (cmbIsActive.SelectedIndex == 0) ? true : false;
             if (selectedRecordId == 0)
             {
                 _objBAL.SaveDepartment(_objModel);
             }
             else
             {
                 _objBAL.UpdateDepartment(_objModel);
             }
             MakeEmpty();
             MessageBox.Show("Record Saved Successfully!");
             FillGrid();
         }
     }
     catch
     { }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
        public async Task <ActionResult> Add(EmployeeRegistrationModel employee)
        {
            if (ModelState.IsValid)
            {
                using (HttpClient httpClient = new HttpClient())
                {
                    string      endPoint = CommonHelper.GetSiteUrl() + "API/Account/register";
                    HttpContent content  = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("firstName", employee.firstName),
                        new KeyValuePair <string, string>("lastName", employee.lastName),
                        new KeyValuePair <string, string>("email", employee.email),
                        new KeyValuePair <string, string>("password", employee.password),
                        new KeyValuePair <string, string>("confirmPassword", employee.confirmPassword),
                        new KeyValuePair <string, string>("departmentId", employee.departmentId.ToString()),
                        new KeyValuePair <string, string>("gender", employee.gender),
                        new KeyValuePair <string, string>("cityId", employee.cityId.ToString()),
                        new KeyValuePair <string, string>("countryId", employee.countryId.ToString()),
                    });

                    HttpResponseMessage result = await httpClient.PostAsync(endPoint, content);

                    string resultContent = result.Content.ReadAsStringAsync().Result;
                    var    response      = JsonConvert.DeserializeObject <AddEmployeeResponse>(resultContent);
                    if (!string.IsNullOrEmpty(response.data.id.ToString()))
                    {
                        ViewBag.Added = "true";
                    }
                }
            }
            ViewBag.DepartmentId = new SelectList(await DepartmentBAL.getDepartment(), "Id", "DepartmentName");
            ViewBag.CountryId    = new SelectList(entity.Countries, "Id", "CountryName");
            ViewBag.CityId       = new SelectList(entity.Cities, "Id", "CityName");
            return(View(employee));
        }
Beispiel #6
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;
            }
        }
    }
 public async Task <ActionResult> Add()
 {
     ViewBag.Added        = "false";
     ViewBag.DepartmentId = new SelectList(await DepartmentBAL.getDepartment(), "Id", "DepartmentName");
     ViewBag.CountryId    = new SelectList(entity.Countries, "Id", "CountryName");
     ViewBag.CityId       = new SelectList(entity.Cities, "Id", "CityName");
     return(View());
 }
Beispiel #8
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;
            }
        }
    }
    public static void fillDropDownListDepartment(DropDownList ddl)
    {
        DepartmentBAL balDepartment = new DepartmentBAL();

        ddl.DataSource     = balDepartment.SelectForDropDownList();
        ddl.DataValueField = "DepartmentID";
        ddl.DataTextField  = "DepartmentName";
        ddl.DataBind();
        ddl.Items.Insert(0, new ListItem(" --Select Department--", "-1"));
    }
Beispiel #10
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();
        }
    }
        private void FillDepartmentList()
        {
            DepartmentBAL          _objBAL        = new DepartmentBAL();
            List <DepartmentModel> DepartmentList = new List <DepartmentModel>();

            DepartmentList              = _objBAL.GetDepartmentList();
            cmbDepartment.DataSource    = DepartmentList;
            cmbDepartment.DisplayMember = "_DeptName";
            cmbDepartment.ValueMember   = "_DeptID";
            cmbDepartment.SelectedIndex = -1;
            cmbDepartment.Text          = "Select Department";
        }
Beispiel #12
0
    public void fillDepartmentGridview()
    {
        DepartmentBAL balDepartment = new DepartmentBAL();
        DataTable     dt            = new DataTable();

        dt = balDepartment.SelectAll();

        if (dt != null && dt.Rows.Count > 0)
        {
            gvDepartment.DataSource = dt;
            gvDepartment.DataBind();
        }
    }
    private void FillGridViewDepartment()
    {
        DepartmentBAL balDepartment = new DepartmentBAL();
        DataTable     dtDepartment  = new DataTable();

        dtDepartment = balDepartment.SelectAll();

        if (dtDepartment != null && dtDepartment.Rows.Count > 0)
        {
            gvDepartment.DataSource = dtDepartment;
            gvDepartment.DataBind();
        }
    }
        public async Task <ActionResult> Edit(EmployeeUpdateModel employee)
        {
            if (ModelState.IsValid)
            {
                bool isUpdated = await UserBAL.updateEmployee(employee);

                if (isUpdated)
                {
                    ViewBag.Updated = "true";
                }
            }
            ViewBag.DepartmentId = new SelectList(await DepartmentBAL.getDepartment(), "Id", "DepartmentName");
            ViewBag.CountryId    = new SelectList(entity.Countries, "Id", "CountryName");
            ViewBag.CityId       = new SelectList(entity.Cities, "Id", "CityName");
            return(View(employee));
        }
 private void FillForm(Int32 _DeptID)
 {
     try
     {
         DepartmentBAL   _objBAL   = new DepartmentBAL();
         DepartmentModel _objModel = _objBAL.SearchDepartment(_DeptID);
         tbxDeptName.Text          = _objModel._DeptName;
         tbxDescription.Text       = _objModel._Description;
         tbxModifiedDate.Text      = _objModel._ModifiedDate.ToShortDateString();
         cmbIsActive.SelectedIndex = (_objModel._IsActive == true) ? 0 : 1;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void FillGrid()
        {
            DepartmentBAL          _objBAL        = new DepartmentBAL();
            List <DepartmentModel> DepartmentList = new List <DepartmentModel>();

            grdDepartment.DataSource = null;
            grdDepartment.Rows.Clear();
            DepartmentList = _objBAL.GetDepartmentList();
            grdDepartment.AutoGenerateColumns = false;
            int count = 0;

            foreach (var item in DepartmentList)
            {
                count++;
                grdDepartment.Rows.Add(item._DeptID, item._DeptName, item._Description, item._ModifiedDate.ToShortDateString());
            }
            tbxCount.Text = count.ToString();;
        }
        public async Task <ActionResult> Edit(long id)
        {
            ViewBag.Updated = "false";
            EmployeeUpdateModel employee;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                employee = await UserBAL.getEmployeeById(id);
            }
            ViewBag.DepartmentId = new SelectList(await DepartmentBAL.getDepartment(), "Id", "DepartmentName", employee.departmentId);
            ViewBag.CountryId    = new SelectList(entity.Countries, "Id", "CountryName", employee.countryId);
            ViewBag.CityId       = new SelectList(entity.Cities, "Id", "CityName", employee.cityId);
            return(View(employee));
        }
 public DepartmentController()
 {
     departmentBAL = new DepartmentBAL();
 }
Beispiel #19
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");
        }
    }