private void LoadBasicData(int materialId)
        {
            MaterialsInformationBasicInformationGateway materialsInformationBasicInformationGateway = new MaterialsInformationBasicInformationGateway(materialsInformationTDS);
            if (materialsInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load material basic data
                hdfProcess.Value = materialsInformationBasicInformationGateway.GetType(materialId);
                tbxProcess.Text = materialsInformationBasicInformationGateway.GetType(materialId);
                tbxState.Text = materialsInformationBasicInformationGateway.GetState(materialId);
                tbxDescription.Text = materialsInformationBasicInformationGateway.GetDescription(materialId);

                if (hdfProcess.Value == "Full Length Lining")
                {
                    ddlThickness.SelectedValue = materialsInformationBasicInformationGateway.GetThickness(materialId);
                    tbxSize.Text = materialsInformationBasicInformationGateway.GetSize(materialId);
                }

                if (hdfProcess.Value == "Point Repairs")
                {
                    ddlPrSize.SelectedValue = materialsInformationBasicInformationGateway.GetSize(materialId);
                    ddlPrLength.SelectedValue = materialsInformationBasicInformationGateway.GetLength(materialId);
                }

                if (hdfProcess.Value == "Junction Lining")
                {
                    string jlDescription = materialsInformationBasicInformationGateway.GetDescription(materialId);
                    if (jlDescription ==  "Lateral / Misc Supplies")
                    {
                        rbtnMiscSupplies.Checked = true;
                    }
                    else
                    {
                        if (jlDescription ==  "Lateral / Cleanout Material")
                        {
                            rbtnCleanoutMaterial.Checked = true;
                        }
                        else
                        {
                            if (jlDescription ==  "Lateral / Backfill - Cleanout")
                            {
                                rbtnBackfillCleanout.Checked = true;
                            }
                            else
                            {
                                tbxJLSize.Text = materialsInformationBasicInformationGateway.GetSize(materialId);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            MaterialsInformationTDS materialsInformationChanges = (MaterialsInformationTDS)Data.GetChanges();

            if (materialsInformationChanges.BasicInformation.Rows.Count > 0)
            {
                MaterialsInformationBasicInformationGateway materialsInformationBasicInformationGateway = new MaterialsInformationBasicInformationGateway(materialsInformationChanges);

                // Update services
                foreach (MaterialsInformationTDS.BasicInformationRow basicInformationRow in (MaterialsInformationTDS.BasicInformationDataTable)materialsInformationChanges.BasicInformation)
                {
                    // Unchanged values
                    int materialId = basicInformationRow.MaterialID;
                    bool deleted = basicInformationRow.Deleted;

                    // Original values
                    string originalDescription = materialsInformationBasicInformationGateway.GetDescriptionOriginal(materialId);
                    string originalSize = materialsInformationBasicInformationGateway.GetSizeOriginal(materialId);
                    string originalLength = materialsInformationBasicInformationGateway.GetLengthOriginal(materialId);
                    string originalThickness = materialsInformationBasicInformationGateway.GetThicknessOriginal(materialId);
                    string originalType = materialsInformationBasicInformationGateway.GetTypeOriginal(materialId);
                    string originalState = materialsInformationBasicInformationGateway.GetStateOriginal(materialId);

                    // New variables
                    string newDescription = materialsInformationBasicInformationGateway.GetDescription(materialId);
                    string newSize = materialsInformationBasicInformationGateway.GetSize(materialId);
                    string newLength = materialsInformationBasicInformationGateway.GetLength(materialId);
                    string newThickness = materialsInformationBasicInformationGateway.GetThickness(materialId);
                    string newType = materialsInformationBasicInformationGateway.GetType(materialId);
                    string newState = materialsInformationBasicInformationGateway.GetState(materialId);

                    // ... Update
                    Materials materials = new Materials(null);
                    materials.UpdateDirect(materialId, originalDescription, originalSize, originalLength, originalThickness, originalType, originalState, deleted, companyId, materialId, newDescription, newSize, newLength, newThickness, newType, newState, deleted, companyId);
                }
            }
        }
        private void LoadBasicData(int materialId)
        {
            MaterialsInformationBasicInformationGateway materialsInformationBasicInformationGateway = new MaterialsInformationBasicInformationGateway(materialsInformationTDS);
            if (materialsInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load material basic data
                tbxDescription.Text = materialsInformationBasicInformationGateway.GetDescription(materialId);
                tbxProcess.Text = materialsInformationBasicInformationGateway.GetType(materialId);
                hdfProcess.Value = tbxProcess.Text;
                tbxSize.Text = materialsInformationBasicInformationGateway.GetSize(materialId);
                tbxState.Text = materialsInformationBasicInformationGateway.GetState(materialId);

                if (tbxProcess.Text == "Point Repairs")
                {
                    tbxThicknessLength.Text = materialsInformationBasicInformationGateway.GetLength(materialId);
                    lblThicknessLength.Text = "Length";
                }
                else
                {
                    if (tbxProcess.Text == "Full Length Lining")
                    {
                        tbxThicknessLength.Text = materialsInformationBasicInformationGateway.GetThickness(materialId);
                        lblThicknessLength.Text = "Thickness";
                    }
                }
            }
        }
        private void UpdateState()
        {
            int materialId = Int32.Parse(hdfMaterialId.Value);
            MaterialsInformationBasicInformationGateway materialsInformationBasicInformationGateway = new MaterialsInformationBasicInformationGateway(materialsInformationTDS);

            // General Data
            string description = materialsInformationBasicInformationGateway.GetDescription(materialId);
            string size = materialsInformationBasicInformationGateway.GetSize(materialId);
            string length = materialsInformationBasicInformationGateway.GetLength(materialId);
            string thickness = materialsInformationBasicInformationGateway.GetThickness(materialId);
            string type = materialsInformationBasicInformationGateway.GetType(materialId);
            int companyId = Int32.Parse(hdfCompanyId.Value);

            // ... Get new values
            string newState = null;
            switch ((string)Request.QueryString["material_state"])
            {
                case "Available":
                    newState = "Not Available";
                    break;

                case "Not Available":
                    newState = "Available";
                    break;
            }

            // Update service data
            MaterialsInformationBasicInformation materialsInformationBasicInformation = new MaterialsInformationBasicInformation(materialsInformationTDS);
            materialsInformationBasicInformation.Update(materialId, description, size, length, thickness, type, newState, false, companyId);
        }