Пример #1
0
        /// <summary>
        /// Set Grid Data source
        /// </summary>
        /// <param name="addRow"></param>
        /// <param name="deleteRow"></param>e
        private void BindGrid(bool addRow, bool deleteRow)
        {
            string      projectID      = Session["PROJECT_ID"].ToString();
            string      WorkflowDefID  = ViewState["WorkFlowDefID"].ToString();
            WorkFlowBLL WorkFlowBLLobj = new WorkFlowBLL();

            grdApprover.DataSource = WorkFlowBLLobj.GetApprover(projectID, WorkflowDefID);
            grdApprover.DataBind();
        }
Пример #2
0
        /// <summary>
        /// Set edit mode for edit comand
        /// Delete data from the database for delete comand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdApprover_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditRow")
            {
                ViewState["WorkApprovalID"] = e.CommandArgument;
                ADDButton.Visible           = false;
                UpDateButton.Visible        = true;
                CancelButton.Visible        = true;

                GetApprover();
                ;
            }
            else if (e.CommandName == "DeleteRow")
            {
                ViewState["WorkApprovalID"] = e.CommandArgument;

                int level     = 0;
                int sameLavel = 0;

                GridViewRow row = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;
                Literal     litWorkApprovallevel = (Literal)row.FindControl("litWorkApprovallevel");

                WorkFlowBLL  WorkFlowBLLOBJ = new WorkFlowBLL();
                WorkFlowList WorkFlowList   = new WorkFlowList();

                string projectID     = Session["PROJECT_ID"].ToString();
                string WorkflowDefID = ViewState["WorkFlowDefID"].ToString();

                WorkFlowList = WorkFlowBLLOBJ.GetApprover(projectID, WorkflowDefID);

                for (int i = 0; i < WorkFlowList.Count; i++)
                {
                    level = (WorkFlowList[i].LEVEL);
                    if (level == (Convert.ToInt32(litWorkApprovallevel.Text.ToString())))
                    {
                        sameLavel = 0;
                    }
                    else
                    {
                        sameLavel = 1;
                    }
                }

                WorkFlowList = WorkFlowBLLOBJ.GetApprover(projectID, WorkflowDefID);

                if (sameLavel == 0)
                {
                    if (Convert.ToInt32(ViewState["WorkApprovalID"]) != 0)
                    {
                        int result = 0;


                        result = DeleteApprover();
                        if (result == 0)
                        {
                            string message      = "Approver Already in use";
                            string AlertMessage = "alert('" + message + "');";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        }
                        else if (result == -1)
                        {
                            string message      = "Data Deleted successfully";
                            string AlertMessage = "alert('" + message + "');";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        }

                        BindGrid(false, true);
                        ADDButton.Visible    = true;
                        UpDateButton.Visible = false;
                        CancelButton.Visible = false;
                        getAllRole();
                        getLevel();
                    }
                }
                else
                {
                    string message      = "Delete Higher Level Approver First";
                    string AlertMessage = "alert('" + message + "');";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// To save or edit details to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ADDButton_Click(object sender, EventArgs e)
        {
            string message      = string.Empty;
            string AlertMessage = string.Empty;


            WorkFlowBLL  WorkFlowBLLOBJ = new WorkFlowBLL();
            WorkFlowList WorkFlowList   = new WorkFlowList();
            int          level          = 0;
            int          count;
            int          sameLavel         = 0;
            string       projectID         = Session["PROJECT_ID"].ToString();
            string       testWorkflowDefID = ViewState["WorkFlowDefID"].ToString();
            string       WorkflowDefID     = ViewState["WorkFlowDefID"].ToString();

            WorkFlowList = WorkFlowBLLOBJ.GetApprover(projectID, WorkflowDefID);
            if (WorkFlowList.Count == 0)
            {
                level = level + 1;
                if (level == (Convert.ToInt32(ApproverLevelDropDownList.SelectedItem.Value.ToString())))
                {
                    sameLavel = 0;
                }
                else
                {
                    sameLavel = 1;
                }
            }
            else
            {
                for (int i = 0; i < WorkFlowList.Count; i++)
                {
                    if (WorkApproverIDTextBox.Text != "0")
                    {
                        level = (WorkFlowList[i].LEVEL);
                        if (level == (Convert.ToInt32(ApproverLevelDropDownList.SelectedItem.Value.ToString())))
                        {
                            sameLavel = 0;
                        }
                        else
                        {
                            sameLavel = 1;
                            break;
                        }
                    }
                    else
                    {
                        level = (WorkFlowList[i].LEVEL) + 1;
                        if (level == (Convert.ToInt32(ApproverLevelDropDownList.SelectedItem.Value.ToString())))
                        {
                            sameLavel = 0;
                        }
                        else
                        {
                            sameLavel = 1;
                        }
                    }
                }
            }

            if (WorkApproverIDTextBox.Text != "0")
            {
                #region for update
                if (sameLavel == 0)
                {
                    string     uID         = Session["USER_ID"].ToString();
                    string     pID         = Session["PROJECT_ID"].ToString();
                    WorkFlowBO objWorkFlow = new WorkFlowBO();

                    objWorkFlow.ApprovalID     = Convert.ToInt32(ApproverRoleNameDropDownList.SelectedItem.Value.ToString());
                    objWorkFlow.ApproverUserID = Convert.ToInt32(ApproverNameDropDownList.SelectedItem.Value.ToString());
                    objWorkFlow.LEVEL          = Convert.ToInt32(ApproverLevelDropDownList.SelectedItem.Value.ToString());
                    objWorkFlow.UserID         = Convert.ToInt32(uID);
                    objWorkFlow.ProjectID      = Convert.ToInt32(pID);
                    objWorkFlow.WorkFlowDefID  = Convert.ToInt32(WorkDefinationTextBox.Text.ToString());
                    objWorkFlow.WorkApprovalID = Convert.ToInt32(ViewState["WorkApprovalID"]);

                    count = WorkFlowBLLOBJ.EditAPPROVALADD(objWorkFlow);
                    if (count == 1)
                    {
                        message      = "Approver or Level Already Exists";
                        AlertMessage = "alert('" + message + "');";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        BindGrid(true, true);
                        ADDButton.Visible          = true;
                        UpDateButton.Visible       = false;
                        CancelButton.Visible       = false;
                        WorkApproverIDTextBox.Text = "0";
                        WorkDefinationTextBox.Text = "0";
                        ListItem lstItem = ApproverNameDropDownList.Items[0];
                        ApproverNameDropDownList.Items.Clear();
                        ApproverNameDropDownList.Items.Insert(0, lstItem);
                        ApproverLevelDropDownList.Enabled = true;
                    }
                    else if (count == -1)
                    {
                        message      = "Approver updated successfully";
                        AlertMessage = "alert('" + message + "');";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        BindGrid(true, true);
                        ADDButton.Visible          = true;
                        UpDateButton.Visible       = false;
                        CancelButton.Visible       = false;
                        WorkApproverIDTextBox.Text = "0";
                        WorkDefinationTextBox.Text = "0";
                        ListItem lstItem = ApproverNameDropDownList.Items[0];
                        ApproverNameDropDownList.Items.Clear();
                        ApproverNameDropDownList.Items.Insert(0, lstItem);
                        ApproverLevelDropDownList.Enabled = true;
                    }
                }
                else
                {
                    message      = "Approver or Level Already Exists";
                    AlertMessage = "alert('" + message + "');";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                    BindGrid(true, true);
                    ADDButton.Visible          = true;
                    UpDateButton.Visible       = false;
                    CancelButton.Visible       = false;
                    WorkApproverIDTextBox.Text = "0";
                    WorkDefinationTextBox.Text = "0";
                    ListItem lstItem = ApproverNameDropDownList.Items[0];
                    ApproverNameDropDownList.Items.Clear();
                    ApproverNameDropDownList.Items.Insert(0, lstItem);
                    ApproverLevelDropDownList.Enabled = true;
                    //getAllRole();
                }
                getAllRole();
                getLevel();
                #endregion
            }
            else
            {
                #region For Save
                try
                {
                    if (sameLavel == 0)
                    {
                        string     uID         = Session["USER_ID"].ToString();
                        string     pID         = Session["PROJECT_ID"].ToString();
                        WorkFlowBO objWorkFlow = new WorkFlowBO();

                        objWorkFlow.ApprovalID     = Convert.ToInt32(ApproverRoleNameDropDownList.SelectedItem.Value.ToString());
                        objWorkFlow.ApproverUserID = Convert.ToInt32(ApproverNameDropDownList.SelectedItem.Value.ToString());
                        objWorkFlow.LEVEL          = Convert.ToInt32(ApproverLevelDropDownList.SelectedItem.Value.ToString());
                        objWorkFlow.UserID         = Convert.ToInt32(uID);
                        objWorkFlow.ProjectID      = Convert.ToInt32(pID);
                        objWorkFlow.WorkFlowDefID  = Convert.ToInt32(ViewState["WorkFlowDefID"]);

                        count = WorkFlowBLLOBJ.InsertAPPROVALADD(objWorkFlow);
                        if (count == 1)
                        {
                            message      = "Approver or Level Already Exists";
                            AlertMessage = "alert('" + message + "');";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                            BindGrid(true, true);
                            getAllRole();
                            getLevel();
                            ListItem lstItem = ApproverNameDropDownList.Items[0];
                            ApproverNameDropDownList.Items.Clear();
                            ApproverNameDropDownList.Items.Insert(0, lstItem);
                        }
                        else if (count == -1)
                        {
                            message      = "Approver Added successfully";
                            AlertMessage = "alert('" + message + "');";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                            BindGrid(true, true);
                            getAllRole();
                            getLevel();
                            ListItem lstItem = ApproverNameDropDownList.Items[0];
                            ApproverNameDropDownList.Items.Clear();
                            ApproverNameDropDownList.Items.Insert(0, lstItem);
                        }
                    }
                    else
                    {
                        message      = " Approvers are Not Defined for Previous Level(s) ";
                        AlertMessage = "alert('" + message + "');";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        BindGrid(true, true);
                        getAllRole();
                        getLevel();
                        ListItem lstItem = ApproverNameDropDownList.Items[0];
                        ApproverNameDropDownList.Items.Clear();
                        ApproverNameDropDownList.Items.Insert(0, lstItem);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                finally
                {
                    WorkFlowBLLOBJ = null;
                }
                #endregion
            }
        }