Beispiel #1
0
        protected void imgBtnInsert_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                if (Session["RespMaintData"] != null)
                {
                    DataTable dtResponsibilityData = Session["RespMaintData"] as DataTable;
                    if (dtResponsibilityData.Select("responsibility_code = '" + txtResponsibilityCode.Text + "'").Length != 0)
                    {
                        msgView.SetMessage("Cannot save - Responsibility already exists with this Code.", MessageType.Success, PositionType.Auto);
                        return;
                    }
                    else if (dtResponsibilityData.Select("responsibility_desc = '" + txtResponsibilityDesc.Text + "'").Length != 0)
                    {
                        msgView.SetMessage("Cannot save - Responsibility already exists with this Name.", MessageType.Success, PositionType.Auto);
                        return;
                    }
                }

                string userCode = WebUtility.HtmlDecode(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());

                responsibilityMaintenanceBL = new ResponsibilityMaintenanceBL();
                DataSet responsibilityData = responsibilityMaintenanceBL.InsertResponsibilityData(txtResponsibilityCode.Text.Trim(), txtResponsibilityDesc.Text.Trim(), ddlNewManagerResp.SelectedValue, userCode, out errorId);
                responsibilityMaintenanceBL = null;

                if (responsibilityData.Tables.Count != 0 && errorId != 2)
                {
                    Session["RespMaintData"]     = responsibilityData.Tables[0];
                    Session["RespMaintMngrResp"] = responsibilityData.Tables[1];
                    Session["FuzzySearchAllResponsibilityList"] = responsibilityData.Tables[2];

                    BindGrid(responsibilityData.Tables[0]);
                    PopulateDropdowns(responsibilityData.Tables[1]);
                    txtResponsibilityDesc.Text      = string.Empty;
                    txtResponsibilityCode.Text      = string.Empty;
                    txtResponsibilitySearch.Text    = string.Empty;
                    ddlNewManagerResp.SelectedIndex = 0;
                    hdnChangeNotSaved.Value         = "N";
                    hdnInsertDataNotSaved.Value     = "N";
                    hdnGridRowSelectedPrvious.Value = null;
                    msgView.SetMessage("Responsibility created successfully.", MessageType.Success, PositionType.Auto);
                }
                else
                {
                    msgView.SetMessage("Failed to create responsibility.", MessageType.Warning, PositionType.Auto);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in creating responsibility.", ex.Message);
            }
        }
Beispiel #2
0
        //JIRA-908 CHanges by Ravi on 13/02/2019 -- End
        #endregion Events

        #region Methods

        private void LoadData()
        {
            responsibilityMaintenanceBL = new ResponsibilityMaintenanceBL();
            DataSet initialData = responsibilityMaintenanceBL.GetInitialData(out errorId);

            responsibilityMaintenanceBL = null;

            if (initialData.Tables.Count != 0 && errorId != 2)
            {
                Session["RespMaintData"]     = initialData.Tables[0];
                Session["RespMaintMngrResp"] = initialData.Tables[1];

                BindGrid(initialData.Tables[0]);
                PopulateDropdowns(initialData.Tables[1]);
            }
            else
            {
                ExceptionHandler("Error in fetching filter list data", string.Empty);
            }
        }
Beispiel #3
0
        //JIRA-908 CHanges by Ravi on 13/02/2019 -- Start
        protected void btnYes_Click(object sender, EventArgs e)
        {
            try
            {
                string responsibilityCode = hdnRespCode.Value;
                responsibilityMaintenanceBL = new ResponsibilityMaintenanceBL();
                DataSet responsibilityData = responsibilityMaintenanceBL.DeleteResponsibilityData(responsibilityCode, Convert.ToString(Session["UserCode"]), out errorId);
                responsibilityMaintenanceBL = null;

                if (errorId == 1)
                {
                    msgView.SetMessage("Cannot delete this Responsibility as it is linked to Artists/Contracts.", MessageType.Success, PositionType.Auto);
                }
                else if (responsibilityData.Tables.Count != 0 && errorId == 0)
                {
                    Session["RespMaintData"]     = responsibilityData.Tables[0];
                    Session["RespMaintMngrResp"] = responsibilityData.Tables[1];
                    Session["FuzzySearchAllResponsibilityList"] = responsibilityData.Tables[2];

                    BindGrid(responsibilityData.Tables[0]);
                    PopulateDropdowns(responsibilityData.Tables[1]);
                    txtResponsibilitySearch.Text           = string.Empty;
                    ddlManagerResponsibility.SelectedIndex = 0;
                    hdnChangeNotSaved.Value         = "N";
                    hdnGridRowSelectedPrvious.Value = null;
                    msgView.SetMessage("Responsibility deleted successfully.", MessageType.Success, PositionType.Auto);
                    hdnRespCode.Value = "";
                }
                else
                {
                    msgView.SetMessage("Failed to delete responsibility.", MessageType.Warning, PositionType.Auto);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Failed to delete responsibility.", ex.Message);
            }
        }
Beispiel #4
0
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            try
            {
                if (hdnInsertDataNotSaved.Value == "Y")
                {
                    //Validate
                    Page.Validate("valInsertResponsibility");
                    if (!Page.IsValid)
                    {
                        mpeSaveUndo.Hide();
                        msgView.SetMessage("Invalid data entered.Please correct.", MessageType.Warning, PositionType.Auto);
                        return;
                    }

                    if (Session["RespMaintData"] != null)
                    {
                        DataTable dtResponsibilityData = Session["RespMaintData"] as DataTable;
                        if (dtResponsibilityData.Select("responsibility_code = '" + txtResponsibilityCode.Text + "'").Length != 0)
                        {
                            msgView.SetMessage("Responsibility already exists with this responsibility code.", MessageType.Success, PositionType.Auto);
                            return;
                        }
                        else if (dtResponsibilityData.Select("responsibility_desc = '" + txtResponsibilityDesc.Text + "'").Length != 0)
                        {
                            msgView.SetMessage("Responsibility already exists with this responsibility desc.", MessageType.Success, PositionType.Auto);
                            return;
                        }
                    }


                    string userCode = WebUtility.HtmlDecode(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());

                    responsibilityMaintenanceBL = new ResponsibilityMaintenanceBL();
                    DataSet responsibilityData = responsibilityMaintenanceBL.InsertResponsibilityData(txtResponsibilityCode.Text.Trim(), txtResponsibilityDesc.Text.Trim(), ddlNewManagerResp.SelectedValue, userCode, out errorId);
                    responsibilityMaintenanceBL = null;

                    if (responsibilityData.Tables.Count != 0 && errorId != 2)
                    {
                        Session["RespMaintData"]     = responsibilityData.Tables[0];
                        Session["RespMaintMngrResp"] = responsibilityData.Tables[1];
                        Session["FuzzySearchAllResponsibilityList"] = responsibilityData.Tables[2];

                        BindGrid(responsibilityData.Tables[0]);
                        PopulateDropdowns(responsibilityData.Tables[1]);
                        txtResponsibilityDesc.Text      = string.Empty;
                        txtResponsibilityCode.Text      = string.Empty;
                        txtResponsibilitySearch.Text    = string.Empty;
                        ddlNewManagerResp.SelectedIndex = 0;
                        hdnChangeNotSaved.Value         = "N";
                        hdnInsertDataNotSaved.Value     = "N";
                        hdnGridRowSelectedPrvious.Value = null;
                        msgView.SetMessage("Responsibility created successfully.", MessageType.Success, PositionType.Auto);
                    }
                    else
                    {
                        msgView.SetMessage("Failed create responsibility.", MessageType.Warning, PositionType.Auto);
                    }
                }
                else if (hdnChangeNotSaved.Value == "Y")
                {
                    //Validate
                    Page.Validate("valUpdateResponsibility");
                    if (!Page.IsValid)
                    {
                        mpeSaveUndo.Hide();
                        msgView.SetMessage("Invalid data entered.Please correct.", MessageType.Warning, PositionType.Auto);
                        return;
                    }

                    string userCode              = WebUtility.HtmlDecode(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());
                    int    rowIndex              = Convert.ToInt32(hdnGridRowSelectedPrvious.Value);
                    string responsibilityCode    = ((Label)gvResponsibilityDetails.Rows[rowIndex].FindControl("lblResponsibilityCode")).Text;
                    string responsibilityDesc    = ((TextBox)gvResponsibilityDetails.Rows[rowIndex].FindControl("txtResponsibilityName")).Text;
                    string managerResponsibility = ((DropDownList)gvResponsibilityDetails.Rows[rowIndex].FindControl("ddlGridManagerResp")).SelectedValue;

                    responsibilityMaintenanceBL = new ResponsibilityMaintenanceBL();
                    DataSet responsibilityData = responsibilityMaintenanceBL.UpdateResponsibilityData(responsibilityCode, responsibilityDesc, managerResponsibility, userCode, out errorId);
                    responsibilityMaintenanceBL = null;

                    if (responsibilityData.Tables.Count != 0 && errorId != 2)
                    {
                        Session["RespMaintData"]     = responsibilityData.Tables[0];
                        Session["RespMaintMngrResp"] = responsibilityData.Tables[1];
                        Session["FuzzySearchAllResponsibilityList"] = responsibilityData.Tables[2];

                        //check if there is only one row in the grid before binding updated data.
                        //if count is 1 then only display that row
                        if (gvResponsibilityDetails.Rows.Count == 1)
                        {
                            DataTable dtSearched = responsibilityData.Tables[0].Clone();
                            DataRow[] foundRows  = responsibilityData.Tables[0].Select("responsibility_code = '" + responsibilityCode + "'");
                            if (foundRows.Length != 0)
                            {
                                dtSearched = foundRows.CopyToDataTable();
                                BindGrid(dtSearched);
                            }
                        }
                        else
                        {
                            BindGrid(responsibilityData.Tables[0]);
                        }
                        PopulateDropdowns(responsibilityData.Tables[1]);
                        hdnChangeNotSaved.Value         = "N";
                        hdnGridRowSelectedPrvious.Value = null;
                        msgView.SetMessage("Responsibility details updated successfully.", MessageType.Success, PositionType.Auto);
                    }
                    else
                    {
                        msgView.SetMessage("Failed to updated responsibility details.", MessageType.Warning, PositionType.Auto);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in saving grid data", ex.Message);
            }
        }
Beispiel #5
0
        //JIRA-746 CHanges by Ravi on 05/03/2019 -- End

        protected void gvResponsibilityDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                string userCode = WebUtility.HtmlDecode(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());

                if (e.CommandName == "saverow")
                {
                    //Validate
                    Page.Validate("valUpdateResponsibility");
                    if (!Page.IsValid)
                    {
                        mpeSaveUndo.Hide();
                        msgView.SetMessage("Invalid data entered.Please correct.", MessageType.Warning, PositionType.Auto);
                        return;
                    }

                    if (!string.IsNullOrEmpty(hdnGridRowSelectedPrvious.Value))
                    {
                        int rowIndex = Convert.ToInt32(hdnGridRowSelectedPrvious.Value);
                        //int rowIndex = ((GridViewRow)((ImageButton)(e.CommandSource)).NamingContainer).RowIndex;
                        string responsibilityCode    = ((Label)gvResponsibilityDetails.Rows[rowIndex].FindControl("lblResponsibilityCode")).Text;
                        string responsibilityDesc    = ((TextBox)gvResponsibilityDetails.Rows[rowIndex].FindControl("txtResponsibilityName")).Text;
                        string managerResponsibility = ((DropDownList)gvResponsibilityDetails.Rows[rowIndex].FindControl("ddlGridManagerResp")).SelectedValue;

                        responsibilityMaintenanceBL = new ResponsibilityMaintenanceBL();
                        DataSet responsibilityData = responsibilityMaintenanceBL.UpdateResponsibilityData(responsibilityCode, responsibilityDesc, managerResponsibility, userCode, out errorId);
                        responsibilityMaintenanceBL = null;

                        if (responsibilityData.Tables.Count != 0 && errorId != 2)
                        {
                            Session["RespMaintData"]     = responsibilityData.Tables[0];
                            Session["RespMaintMngrResp"] = responsibilityData.Tables[1];
                            Session["FuzzySearchAllResponsibilityList"] = responsibilityData.Tables[2];

                            //check if there is only one row in the grid before binding updated data.
                            //if count is 1 then only display that row
                            if (gvResponsibilityDetails.Rows.Count == 1)
                            {
                                DataTable dtSearched = responsibilityData.Tables[0].Clone();
                                DataRow[] foundRows  = responsibilityData.Tables[0].Select("responsibility_code = '" + responsibilityCode + "'");
                                if (foundRows.Length != 0)
                                {
                                    dtSearched = foundRows.CopyToDataTable();
                                    BindGrid(dtSearched);
                                }
                            }
                            else
                            {
                                BindGrid(responsibilityData.Tables[0]);
                            }
                            PopulateDropdowns(responsibilityData.Tables[1]);
                            hdnChangeNotSaved.Value         = "N";
                            hdnGridRowSelectedPrvious.Value = null;
                            msgView.SetMessage("Responsibility details updated successfully.", MessageType.Success, PositionType.Auto);
                        }
                        else
                        {
                            msgView.SetMessage("Failed to updated responsibility details.", MessageType.Warning, PositionType.Auto);
                        }
                    }
                }
                else if (e.CommandName == "cancelrow")
                {
                    if (Session["RespMaintData"] != null)
                    {
                        DataTable dtResponsibilityData = Session["RespMaintData"] as DataTable;
                        if (gvResponsibilityDetails.Rows.Count == 1)
                        {
                            string responsibilityDesc = ((Label)gvResponsibilityDetails.Rows[0].FindControl("lblResponsibilityName")).Text;

                            ((TextBox)gvResponsibilityDetails.Rows[0].FindControl("txtResponsibilityName")).Text = responsibilityDesc;
                        }
                        else
                        {
                            BindGrid(dtResponsibilityData);
                            txtResponsibilitySearch.Text = string.Empty;
                        }
                        hdnChangeNotSaved.Value         = "N";
                        hdnGridRowSelectedPrvious.Value = null;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error in saving/deleting responsibility data.", ex.Message);
            }
        }