Ejemplo n.º 1
0
        /*Funcion: Construir unidades a partir del DAO
          Param: DataTable
          Return: Lista Unit
          */
        public List<UnitView> buildUnits(DataTable DaoResult)
        {
            List<UnitView> ViewList = new List<UnitView>();

            foreach (DataRow row in DaoResult.Rows)
            {
                UnitView x = new UnitView();
                if (DaoResult.Columns.Contains("UnitId") && row["UnitId"] != DBNull.Value) { x.UnitId = Convert.ToInt32(row["UnitId"]); }
                if (DaoResult.Columns.Contains("UnitName") && row["UnitName"] != DBNull.Value) { x.UnitName = row["UnitName"].ToString(); }
                if (DaoResult.Columns.Contains("UnitSymbol") && row["UnitSymbol"] != DBNull.Value) { x.UnitSymbol = row["UnitSymbol"].ToString(); }

                ViewList.Add(x);
            }
            return ViewList;
        }
Ejemplo n.º 2
0
        /*Funcion: Actualizar Units
          Param: UnitView,AuditDataFromWeb
          Return: Status
          */
        public CUDView updateUnits(UnitView unit, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getUnitByUnitId(unit.UnitId);
            String OldValues = "UnitId: " + unit.UnitId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("UnitName") && row["UnitName"] != DBNull.Value) { OldValues = OldValues + ", UnitName: " + row["UnitName"].ToString(); }
                if (auditDaoResult.Columns.Contains("UnitSymbol") && row["UnitSymbol"] != DBNull.Value) { OldValues = OldValues + ", UnitSymbol: " + row["UnitSymbol"].ToString(); }

            }

            ParameterDao Dao = new ParameterDao();
            String state = Dao.updateUnits(unit);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update unit";
                String NewValues = "UnitId: " + unit.UnitId
                    + ", UnitName: " + unit.UnitName
                    + ", UnitSymbol: " + unit.UnitSymbol;

                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }

            return logic;
        }
Ejemplo n.º 3
0
        /*Funcion: Obtener unidad para un parametro
          Param: ParameterId
          Return: Unit
          */
        public UnitView getUnitFromParameter(int ParameterId )
        {
            ParameterDao Dao = new ParameterDao();
            DataTable DaoResult = Dao.getUnitFromParameter(ParameterId);
            UnitView View = new UnitView();

            foreach (DataRow row in DaoResult.Rows)
            {

                if (DaoResult.Columns.Contains("UnitId") && row["UnitId"] != DBNull.Value) { View.UnitId = Convert.ToInt32(row["UnitId"]); }
                if (DaoResult.Columns.Contains("UnitName") && row["UnitName"] != DBNull.Value) { View.UnitName = row["UnitName"].ToString(); }
                if (DaoResult.Columns.Contains("UnitSymbol") && row["UnitSymbol"] != DBNull.Value) { View.UnitSymbol = row["UnitSymbol"].ToString(); }

            }
            return View;
        }
        /*
        Metodo que se utiliza para actualizar la unidad
        */
        private void updateUnitAux()
        {
            if (HttpContext.Current.Session["UnitId"] != null)
            {
                string Name = UnitName.Text;
                string Symbol = UnitSymbol.Text;

                if (Name != "" & Symbol != "")
                {
                    ParameterService parameterService = new ParameterService();

                    String reason = Session["reason"].ToString();
                    String user = Context.User.Identity.Name;
                    AuditDataFromWeb audit = new AuditDataFromWeb();
                    audit.Reason = reason;
                    audit.StationIP = General.getIp(this.Page);
                    audit.UserName = user;

                    UnitView unit = new UnitView();
                    unit.UnitName = Name;
                    unit.UnitSymbol = Symbol;
                    unit.UnitId = Int32.Parse(HttpContext.Current.Session["UnitId"].ToString());
                    CUDView crud = parameterService.updateUnits(unit, audit);

                    if (crud.update == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Value')", true);
                    }
                    else
                    {
                        UnitName.Text = "";
                        UnitSymbol.Text = "";

                        fillUnitGroupTable();
                        updateUnitModal.Update();
                    }
                    HttpContext.Current.Session["operation"] = "create";
                    showUnitModal();
                }
            }
        }
        protected void updateUnit_Click(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["UnitId"] != null)
            {
                string Name = UnitName.Text;
                string Symbol = UnitSymbol.Text;

                if (Name != "" & Symbol != "")
                {
                    ParameterService parameterService = new ParameterService();

                    UnitView unit = new UnitView();
                    unit.UnitName = Name;
                    unit.UnitSymbol = Symbol;
                    unit.UnitId = Int32.Parse(HttpContext.Current.Session["UnitId"].ToString());
                    CUDView crud = parameterService.updateUnits(unit);

                    if (crud.update == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Value')", true);
                    }
                    else
                    {
                        UnitName.Text = "";
                        UnitSymbol.Text = "";

                        fillUnitGroupTable();
                        updateUnitModal.Update();
                    }
                }
            }
        }
Ejemplo n.º 6
0
 /*
   Funcion: Actualiza Unidades
   Param: UnitId, UnitName, UnitSymbol
   Return: Status
   */
 public String updateUnits(UnitView unit)
 {
     return context.InsertUpdateDeleteMSQL("EXEC updateUnit @UnitId=" + unit.UnitId + ", @UnitName='" + unit.UnitName + "', @UnitSymbol='" + unit.UnitSymbol + "'");
 }