private void BindAll()
        {
            MatListview.DataSource = Preview.Preview_DM(docnum, entitycode);
            MatListview.DataBind();
            TAMat.InnerText  = Preview.preview_total_directmaterials(docnum);
            ETAMat.InnerText = Preview.preview_requestedtotal_directmaterials(docnum);

            OpexListiview.DataSource = Preview.Preview_OP(docnum, entitycode);
            OpexListiview.DataBind();
            TAOpex.InnerText  = Preview.preview_total_opex(docnum);
            ETAOpex.InnerText = Preview.preview_requestedtotal_opex(docnum);

            ManListview.DataSource = Preview.Preview_MAN(docnum, entitycode);
            ManListview.DataBind();
            TAManpower.InnerText  = Preview.preview_total_manpower(docnum);
            ETAManpower.InnerText = Preview.preview_requestedtotal_manpower(docnum);
            //ATAManpower.InnerText = MRPClass.manpower_approved_total().ToString("N");

            CapexListview.DataSource = Preview.Preview_CA(docnum, entitycode);
            CapexListview.DataBind();
            TACapex.InnerText  = Preview.preview_total_capex(docnum);
            ETACapex.InnerText = Preview.preview_requestedtotal_capex(docnum);

            RevListview.DataSource = Preview.Preview_Revenue(DocNum.Text.ToString(), entitycode);
            RevListview.DataBind();
            TARevenue.InnerText = MRPClass.revenue_total().ToString("N");

            PreviewListSummary.DataSource = Preview.MRP_PrevTotalSummary(DocNum.Text.ToString(), entitycode);
            PreviewListSummary.DataBind();
            TotalAmountSummary.InnerText = Preview.Prev_Summary_Total();
        }
        private void Load_MRP(string docnumber)
        {
            string query = "SELECT tbl_MRP_List.*, " +
                           " vw_AXEntityTable.NAME AS EntityCodeDesc, " +
                           " vw_AXOperatingUnitTable.NAME AS BUCodeDesc, " +
                           " tbl_MRP_Status.StatusName, tbl_Users.Lastname, " +
                           " tbl_Users.Firstname, tbl_MRP_List.EntityCode, " +
                           " tbl_MRP_List.BUCode " +
                           " FROM tbl_MRP_List LEFT OUTER JOIN tbl_Users ON tbl_MRP_List.CreatorKey = tbl_Users.PK " +
                           " LEFT OUTER JOIN vw_AXOperatingUnitTable ON tbl_MRP_List.BUCode = vw_AXOperatingUnitTable.OMOPERATINGUNITNUMBER " +
                           " LEFT OUTER JOIN tbl_MRP_Status ON tbl_MRP_List.StatusKey = tbl_MRP_Status.PK " +
                           " LEFT OUTER JOIN vw_AXEntityTable ON tbl_MRP_List.EntityCode = vw_AXEntityTable.ID " +
                           " WHERE dbo.tbl_MRP_List.DocNumber = '" + docnumber + "' " +
                           " ORDER BY dbo.tbl_MRP_List.DocNumber DESC";
            SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString());

            conn.Open();

            SqlCommand    cmd    = new SqlCommand(query, conn);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                //DocNum.Text = reader["DocNumber"].ToString();
                //DateCreated.Text = reader["DateCreated"].ToString();
                mrp_key         = Convert.ToInt32(reader["PK"]);
                entitycode      = reader["EntityCode"].ToString();
                dateCreated     = Convert.ToDateTime(reader["DateCreated"]);
                EntityCode.Text = reader["EntityCodeDesc"].ToString();
                buCode          = reader["BUCode"].ToString();
                BUCode.Text     = reader["BUCodeDesc"].ToString();
                Month.Text      = MRPClass.Month_Name(Int32.Parse(reader["MRPMonth"].ToString()));
                Year.Text       = reader["MRPYear"].ToString();
                Creator.Text    = EncryptionClass.Decrypt(reader["Firstname"].ToString()) + " " + EncryptionClass.Decrypt(reader["Lastname"].ToString());
                Status.Text     = reader["StatusName"].ToString();
                //Status.Text = reader["StatusName"].ToString();
            }
            reader.Close();
            conn.Close();


            iStatusKey = MRPClass.MRP_Line_Status(mrp_key, wrkflwln);
            StatusHidden["hidden_preview_iStatusKey"] = iStatusKey;
            WrkFlowHidden["hidden_preview_wrkflwln"]  = wrkflwln;

            string docnum = DocNum.Text.ToString();

            CapexListview.DataSource = Preview.Preview_CA(docnum, entitycode);
            CapexListview.DataBind();
            TotalAmountTD.InnerText = Preview.preview_total_capex(docnum);

            DataTable tableMat = Preview.Preview_DM(docnum, entitycode);

            MatListview.DataSource = tableMat;
            MatListview.DataBind();
            TAMat.InnerText = Preview.preview_total_directmaterials(DocNum.Text.ToString());

            DataTable tableOpex = Preview.Preview_OP(docnum, entitycode);

            OpexListiview.DataSource = tableOpex;
            OpexListiview.DataBind();
            TAOpex.InnerText = Preview.preview_total_opex(docnum);

            DataTable tableManpower = Preview.Preview_MAN(docnum, entitycode);

            ManListview.DataSource = tableManpower;
            ManListview.DataBind();
            TAManpower.InnerText = Preview.preview_total_manpower(docnum);

            DataTable tableRevenue = Preview.Preview_Revenue(docnum, entitycode);

            RevListview.DataSource = tableRevenue;
            RevListview.DataBind();
            TARevenue.InnerText = Preview.preview_total_revenue(docnum);

            PreviewListSummary.DataSource = Preview.MRP_PrevTotalSummary(docnum, entitycode);
            PreviewListSummary.DataBind();
            TotalAmountSummary.InnerText = Preview.Prev_Summary_Total();

            MRPClass.trial();
        }