private void BindPO()
        {
            DataTable dtRecord = MRPClass.PO_Table();

            POTable.DataSource   = dtRecord;
            POTable.KeyFieldName = "PK";
            POTable.DataBind();
        }
        protected void POTable_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e)
        {
            if (Session["CreatorKey"] == null)
            {
                Response.RedirectLocation = "default.aspx";
                return;
            }
            ASPxHiddenField text = POTable.FindHeaderTemplateControl(POTable.Columns[0], "HiddenVal") as ASPxHiddenField;

            text["hidden_value"] = "";

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

            conn.Open();
            string PK    = POTable.GetRowValues(POTable.FocusedRowIndex, "PK").ToString();
            string query = "SELECT COUNT(*) FROM " + MRPClass.POTableName() + " WHERE CreatorKey = '" + Session["CreatorKey"].ToString() + "' AND PK = '" + PK + "'";

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

            if (result > 0)
            {
                if (e.ButtonID == "Edit")
                {
                    if (POTable.FocusedRowIndex > -1)
                    {
                        Session["PO_PK"] = PK;
                        string docNum   = POTable.GetRowValues(POTable.FocusedRowIndex, "MRPNumber").ToString();
                        string poNumber = POTable.GetRowValues(POTable.FocusedRowIndex, "PONumber").ToString();
                        Session["MRP_Number"] = docNum;

                        //query if po number already PO

                        //string query_po = "SELECT COUNT(*) FROM[dbo].[tbl_POCreation_Details] WHERE PONumber = '" + poNumber + "'";
                        //SqlCommand cmd = new SqlCommand(query_po, conn);
                        //int result_po = Convert.ToInt32(cmd.ExecuteScalar());
                        //MRPClass.PrintString(":" + result_po);
                        //if (result_po > 0)
                        //    text["hidden_value"] = "AlreadyPO";
                        //else
                        Response.RedirectLocation = "mrp_pocreatededit.aspx?PONum=" + poNumber.ToString();

//                         string query_po = "SELECT COUNT(*) FROM[dbo].[tbl_POCreation_Details] WHERE PONumber = '" + poNumber + "'";
//                         SqlCommand cmd = new SqlCommand(query_po, conn);
//                         int result_po = Convert.ToInt32(cmd.ExecuteScalar());
//                         //MRPClass.PrintString(":" + result_po);
//                         if (result_po > 0)
//                             text["hidden_value"] = "AlreadyPO";
//                         else
//                             Response.RedirectLocation = "mrp_poaddedit.aspx?DocNum=" + docNum.ToString();
                    }
                }

                if (e.ButtonID == "Delete")
                {
                    if (POTable.FocusedRowIndex > -1)
                    {
                        string     delete = "DELETE FROM " + MRPClass.POTableName() + " WHERE [PK] ='" + PK + "'";
                        SqlCommand cmd    = new SqlCommand(delete, conn);
                        cmd.ExecuteNonQuery();
                        BindPO();
                    }
                }
            }
            else
            {
                text["hidden_value"] = "InvalidCreator";
            }
        }