public void OnFlowFinish()
 {
     //Log.Debug(($"{GetType().Name}->OnFlowFinish {CurrentWorkFlow.GetType().Name} {CurrentWorkFlow.PostWorkFlow}"));
     CurrentWorkFlow = CurrentWorkFlow.PostWorkFlow;
     CurrentWorkFlow.Startup();
 }
Beispiel #2
0
 public void OnFlowFinish()
 {
     CurrentWorkFlow = CurrentWorkFlow.PostWorkFlow;
     CurrentWorkFlow.Startup();
 }
 public void Startup()
 {
     CurrentWorkFlow = PostWorkFlow;
     CurrentWorkFlow.Startup();
 }
        protected void MainTable_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e)
        {
            CheckCreatorKey();

            if (Session["CreatorKey"] == null)
            {
                return;
            }

            ASPxHiddenField text       = MainTable.FindHeaderTemplateControl(MainTable.Columns[0], "MRPHiddenVal") as ASPxHiddenField;
            ASPxHiddenField Status     = MainTable.FindHeaderTemplateControl(MainTable.Columns[0], "MRPHiddenValStatus") as ASPxHiddenField;
            ASPxHiddenField StatusLine = MainTable.FindHeaderTemplateControl(MainTable.Columns[0], "MRPHiddenValStatusLine") as ASPxHiddenField;
            //if (e.ButtonID == "Add")
            //{

            //}

            SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString());

            conn.Open();
            docNum          = MainTable.GetRowValues(MainTable.FocusedRowIndex, "DocNumber").ToString();
            PK              = MainTable.GetRowValues(MainTable.FocusedRowIndex, "PK").ToString();
            entCode         = MainTable.GetRowValues(MainTable.FocusedRowIndex, "EntityCode").ToString();
            buCode          = MainTable.GetRowValues(MainTable.FocusedRowIndex, "BUCode").ToString();
            StatusKey       = Convert.ToInt32(MainTable.GetRowValues(MainTable.FocusedRowIndex, "StatusKey").ToString());
            dteCreated      = Convert.ToDateTime(MainTable.GetRowValues(MainTable.FocusedRowIndex, "DateCreated").ToString());
            CurrentWorkFlow = Convert.ToInt32(MainTable.GetRowValues(MainTable.FocusedRowIndex, "WorkflowStatusLine").ToString());

            //MRPClass.PrintString(Session["CreatorKey"].ToString() + " | " + PK.ToString());

            string query = "SELECT COUNT(*) FROM [dbo].[tbl_MRP_List] WHERE CreatorKey = '" + Session["CreatorKey"].ToString() + "' AND PK = '" + PK + "'";

            SqlCommand comm  = new SqlCommand(query, conn);
            int        count = Convert.ToInt32(comm.ExecuteScalar());

            //MRPClass.PrintString(count.ToString());

            if (count > 0)
            {
                text["hidden_value"] = "Creator";
                if (e.ButtonID == "Edit")
                {
                    if (MainTable.FocusedRowIndex > -1)
                    {
                        string mrp_pk      = MainTable.GetRowValues(MainTable.FocusedRowIndex, "PK").ToString();
                        string mrp_creator = MainTable.GetRowValues(MainTable.FocusedRowIndex, "CreatorKey").ToString();

                        Session["mrp_creator"] = mrp_creator;

                        Session["mrp_docNum"]  = docNum.ToString();
                        Session["mrp_wrkLine"] = "0";

                        //DEBUGGING ONLY
                        Response.RedirectLocation = "mrp_addedit.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=0";
                    }
                }

                if (e.ButtonID == "Delete")
                {
                    //msgTrans.Text = "Pass Delete";
                    if (MainTable.FocusedRowIndex > -1)
                    {
                        Status["hidden_value"] = MainTable.GetRowValues(MainTable.FocusedRowIndex, "StatusKey").ToString();
                    }
                }

                if (e.ButtonID == "Submit")
                {
                    if (MainTable.FocusedRowIndex > -1)
                    {
                        //MRPClass.PrintString(StatusKey.ToString());

                        Status["hidden_value"] = MainTable.GetRowValues(MainTable.FocusedRowIndex, "StatusKey").ToString();
                    }
                }

                if (e.ButtonID == "Preview")
                {
                    string mrp_creator = MainTable.GetRowValues(MainTable.FocusedRowIndex, "CreatorKey").ToString();
                    Session["mrp_creator"] = mrp_creator;
                    if (StatusKey == 4)
                    {
                        Session["mrp_docNum"]     = docNum.ToString();
                        Session["source"]         = "0";
                        Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                    }
                    else if (StatusKey == 3)
                    {
                        Session["mrp_docNum"]     = docNum.ToString();
                        Session["mrp_source"]     = "0";
                        Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                    }
                    else if (StatusKey == 2)
                    {
                        if (CurrentWorkFlow == 0 || CurrentWorkFlow == 1)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_wrkLine"]    = "0";
                            Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=0";
                        }
                        else
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_source"]     = "0";
                            Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                        }
                    }
                    else
                    {
                        Session["mrp_docNum"]     = docNum.ToString();
                        Session["mrp_wrkLine"]    = "0";
                        Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=0";
                    }
                }
            }
            else
            {
                if (e.ButtonID == "Edit" || e.ButtonID == "Submit" || e.ButtonID == "Delete")
                {
                    if (e.ButtonID == "Delete" || e.ButtonID == "Submit")
                    {
                        if (GlobalClass.IsSuperAdmin(Convert.ToInt32(Session["CreatorKey"])))
                        {
                            if (MainTable.FocusedRowIndex > -1)
                            {
                                Status["hidden_value"] = MainTable.GetRowValues(MainTable.FocusedRowIndex, "StatusKey").ToString();
                            }
                        }
                        else
                        {
                            text["hidden_value"] = "InvalidCreator";
                        }
                    }
                    else if (e.ButtonID == "Edit")
                    {
                        if (StatusKey == 2)
                        {
                            if (CurrentWorkFlow == 1)
                            {
                                if (GlobalClass.IsAllowed(Convert.ToInt32(Session["CreatorKey"]), "MOPBULead", DateTime.Now, entCode, buCode) || GlobalClass.IsSuperAdmin(Convert.ToInt32(Session["CreatorKey"])))
                                {
                                    string mrp_creator = MainTable.GetRowValues(MainTable.FocusedRowIndex, "CreatorKey").ToString();
                                    Session["mrp_creator"] = mrp_creator;

                                    Session["mrp_docNum"]     = docNum.ToString();
                                    Session["mrp_wrkLine"]    = CurrentWorkFlow;
                                    Response.RedirectLocation = "mrp_addedit.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=" + CurrentWorkFlow.ToString();
                                }
                                else
                                {
                                    text["hidden_value"] = "InvalidCreator";
                                }
                            }
                            else if (CurrentWorkFlow == 2 || CurrentWorkFlow == 3)
                            {
                                if (GlobalClass.IsAllowed(Convert.ToInt32(Session["CreatorKey"]), "MOPInventoryAnalyst", DateTime.Now, entCode, buCode) || GlobalClass.IsSuperAdmin(Convert.ToInt32(Session["CreatorKey"])))
                                {
                                    string mrp_creator = MainTable.GetRowValues(MainTable.FocusedRowIndex, "CreatorKey").ToString();
                                    Session["mrp_creator"] = mrp_creator;

                                    Session["mrp_docNum"]     = docNum.ToString();
                                    Session["mrp_wrkLine"]    = CurrentWorkFlow;
                                    Response.RedirectLocation = "mrp_inventanalyst.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=" + CurrentWorkFlow.ToString();
                                }
                                else
                                {
                                    text["hidden_value"] = "InvalidCreator";
                                }
                            }
                            else
                            {
                                text["hidden_value"] = "InvalidCreator";
                            }
                        }
                        else
                        {
                            text["hidden_value"] = "InvalidCreator";
                        }
                    }
                    else
                    {
                        text["hidden_value"] = "InvalidCreator";
                    }
                }
                else if (e.ButtonID == "Preview")
                {
                    string mrp_creator = MainTable.GetRowValues(MainTable.FocusedRowIndex, "CreatorKey").ToString();
                    Session["mrp_creator"] = mrp_creator;

                    if (GlobalClass.IsSuperAdmin(Convert.ToInt32(Session["CreatorKey"])))
                    {
                        if (StatusKey == 4)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_source"]     = "0";
                            Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                        }
                        else if (StatusKey == 3)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_appLine"]    = CurrentWorkFlow.ToString();
                            Response.RedirectLocation = "mrp_previewforapproval.aspx?DocNum=" + docNum.ToString() + "&ApprvLn=" + CurrentWorkFlow.ToString();
                        }
                        else if (StatusKey == 2)
                        {
                            Session["mrp_docNum"]  = docNum.ToString();
                            Session["mrp_wrkLine"] = CurrentWorkFlow.ToString();
                            if (CurrentWorkFlow == 2 || CurrentWorkFlow == 3)
                            {
                                Response.RedirectLocation = "mrp_preview_inventanalyst.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=" + CurrentWorkFlow.ToString();
                            }
                            else
                            {
                                Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=" + CurrentWorkFlow.ToString();
                            }
                        }
                        else if (StatusKey == 1)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_wrkLine"]    = CurrentWorkFlow.ToString();
                            Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=" + CurrentWorkFlow.ToString();
                        }
                    }
                    else if (GlobalClass.IsAllowed(Convert.ToInt32(Session["CreatorKey"]), "MOPBULead", dteCreated, entCode, buCode) || GlobalClass.IsSuperAdmin(Convert.ToInt32(Session["CreatorKey"])))
                    {
                        if (StatusKey == 4)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_source"]     = "0";
                            Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                        }
                        else if (StatusKey == 3)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_source"]     = "0";
                            Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                        }
                        else if (StatusKey == 2)
                        {
                            if (CurrentWorkFlow == 0 || CurrentWorkFlow == 1)
                            {
                                Session["mrp_docNum"]     = docNum.ToString();
                                Session["mrp_wrkLine"]    = CurrentWorkFlow.ToString();
                                Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=" + CurrentWorkFlow.ToString();
                            }
                            else
                            {
                                Session["mrp_docNum"]     = docNum.ToString();
                                Session["mrp_source"]     = "0";
                                Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                            }
                        }
                        else
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_wrkLine"]    = "0";
                            Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=0";
                        }
                    }
                    else if (GlobalClass.IsAllowed(Convert.ToInt32(Session["CreatorKey"]), "MOPProcurementOfficer", dteCreated, entCode, buCode) || GlobalClass.IsSuperAdmin(Convert.ToInt32(Session["CreatorKey"])))
                    {
                        if (StatusKey == 4)
                        {
                            Session["mrp_docNum"]     = docNum.ToString();
                            Session["mrp_source"]     = "0";
                            Response.RedirectLocation = "mrp_preview_procoff.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                        }
                        else
                        {
                            text["hidden_value"] = "InvalidCreator";
                        }
                    }
                    else
                    {
                        if (Session["CreatorKey"] == Session["mrp_creator"])
                        {
                            if (StatusKey == 4)
                            {
                                Session["mrp_docNum"]     = docNum.ToString();
                                Session["mrp_source"]     = "0";
                                Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                            }
                            else if (StatusKey == 3)
                            {
                                Session["mrp_docNum"]     = docNum.ToString();
                                Session["mrp_source"]     = "0";
                                Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                            }
                            else if (StatusKey == 2)
                            {
                                if (CurrentWorkFlow == 0 || CurrentWorkFlow == 1)
                                {
                                    Session["mrp_docNum"]     = docNum.ToString();
                                    Session["mrp_wrkLine"]    = "0";
                                    Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=0";
                                }
                                else
                                {
                                    Session["mrp_docNum"]     = docNum.ToString();
                                    Session["mrp_source"]     = "0";
                                    Response.RedirectLocation = "mrp_preview_approve.aspx?DocNum=" + docNum.ToString() + "&Source=0";
                                }
                            }
                            else
                            {
                                Session["mrp_docNum"]     = docNum.ToString();
                                Session["mrp_wrkLine"]    = "0";
                                Response.RedirectLocation = "mrp_preview.aspx?DocNum=" + docNum.ToString() + "&WrkFlwLn=0";
                            }
                        }
                        else
                        {
                            text["hidden_value"] = "InvalidCreator";
                        }
                    }
                }
            }
            conn.Close();
        }