private void UpdateDatabase()
        {
            DB.Open();
            DB.BeginTransaction();
            try
            {
                UnitsOfMeasurementNavigator unitsOfMeasurementNavigator = new UnitsOfMeasurementNavigator(unitsOfMeasurementNavigatorTDS);
                unitsOfMeasurementNavigator.Save();

                DB.CommitTransaction();

                // Store datasets
                unitsOfMeasurementNavigatorTDS.AcceptChanges();
                Session["unitsOfMeasurementNavigatorTDS"] = unitsOfMeasurementNavigatorTDS;
                Session["unitsOfMeasurementNavigator"] = unitsOfMeasurementNavigatorTDS.UnitsOfMeasurementNavigator;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
        protected void grdUnitsOfMeasurement_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Page.Validate("dataEdit");
            if (Page.IsValid)
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int unitOfMeasurementId = (int)e.Keys["UnitOfMeasurementID"];
                string description = ((TextBox)grdUnitsOfMeasurement.Rows[e.RowIndex].Cells[1].FindControl("tbxDescriptionEdit")).Text;
                string abbreviation = ((TextBox)grdUnitsOfMeasurement.Rows[e.RowIndex].Cells[1].FindControl("tbxAbbreviationEdit")).Text;

                UnitsOfMeasurementNavigator model = new UnitsOfMeasurementNavigator(unitsOfMeasurementNavigatorTDS);
                model.Update(unitOfMeasurementId, description, abbreviation, false, companyId);

                Session["unitsOfMeasurementNavigatorTDS"] = unitsOfMeasurementNavigatorTDS;
                Session["unitsOfMeasurementNavigator"] = unitsOfMeasurementNavigatorTDS.UnitsOfMeasurementNavigator;
            }
            else
            {
                e.Cancel = true;
            }
        }
        private void GrdUnistOfMeasurementAdd()
        {
            ViewState["pageIndex"] = grdUnitsOfMeasurement.PageIndex;

            if (FooterValidate())
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);

                string description = ((TextBox)grdUnitsOfMeasurement.FooterRow.FindControl("tbxDescriptionNew")).Text.Trim();
                string abbreviation = ((TextBox)grdUnitsOfMeasurement.FooterRow.FindControl("tbxAbbreviationNew")).Text.Trim();

                UnitsOfMeasurementNavigator model = new UnitsOfMeasurementNavigator(unitsOfMeasurementNavigatorTDS);
                model.Insert(description, abbreviation, false, companyId, false);

                Session.Remove("unitOfMeasurementDummy");
                Session["unitsOfMeasurementNavigatorTDS"] = unitsOfMeasurementNavigatorTDS;
                Session["unitsOfMeasurementNavigator"] = unitsOfMeasurementNavigatorTDS.UnitsOfMeasurementNavigator;

                grdUnitsOfMeasurement.DataBind();
                grdUnitsOfMeasurement.PageIndex = grdUnitsOfMeasurement.PageCount - 1;
            }
        }
        protected void grdUnitsOfMeasurement_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Units Of Measurement Gridview, if the gridview is edition mode
            if (grdUnitsOfMeasurement.EditIndex >= 0)
            {
                grdUnitsOfMeasurement.UpdateRow(grdUnitsOfMeasurement.EditIndex, true);
            }

            // Delete unit of Measurement
            int unitOfMeasurementId = (int)e.Keys["UnitOfMeasurementID"];

            UnitsOfMeasurementNavigator model = new UnitsOfMeasurementNavigator(unitsOfMeasurementNavigatorTDS);
            model.Delete(unitOfMeasurementId);

            Session["unitsOfMeasurementNavigatorTDS"] = unitsOfMeasurementNavigatorTDS;
            Session["unitsOfMeasurementNavigator"] = unitsOfMeasurementNavigatorTDS.UnitsOfMeasurementNavigator;
        }