Beispiel #1
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            if (Mode == "New")
            {
                #region Validate

                // Validar nodo
                if (!IsValidNodeName(txtDescription.Text.Trim().ToUpper()))
                {
                    return;
                }

                #endregion

                // Datos de nodo
                nodeDto objNodeDTO = new nodeDto();
                objNodeDTO.v_Description                 = txtDescription.Text.Trim().ToUpper();
                objNodeDTO.v_GeografyLocationId          = txtGeografyLocationId.Text.Trim().ToUpper();
                objNodeDTO.v_GeografyLocationDescription = txtGeografyLocationDescription.Text.Trim().ToUpper();
                objNodeDTO.i_NodeTypeId = Convert.ToInt32(ddlNodeType.SelectedValue);
                objNodeDTO.d_BeginDate  = dpBeginDate.SelectedDate.Value;
                objNodeDTO.d_EndDate    = dpEndDate.SelectedDate == null ? (DateTime?)null : dpEndDate.SelectedDate.Value;

                OperationResult objOperationResult1 = new OperationResult();
                // Graba Nodo
                _objNodeBL.AddNode(ref objOperationResult1, objNodeDTO, ((ClientSession)Session["objClientSession"]).GetAsList());

                if (objOperationResult1.Success != 1)
                {
                    Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult1.ExceptionMessage);
                }
            }
            else if (Mode == "Edit")
            {
                nodeDto objNodeDTO = Session["sobjNodeDTO"] as nodeDto;

                #region Validate Node

                // Almacenar temporalmente el nombre de nodo
                var _nodeNameTemp = objNodeDTO.v_Description;

                if (txtDescription.Text != _nodeNameTemp)
                {
                    // Validar nodo
                    if (!IsValidNodeName(txtDescription.Text.Trim().ToUpper()))
                    {
                        return;
                    }
                }

                #endregion

                // Datos de Nodo
                objNodeDTO.v_Description                 = txtDescription.Text.Trim().ToUpper();
                objNodeDTO.v_GeografyLocationId          = txtGeografyLocationId.Text.Trim().ToUpper();
                objNodeDTO.v_GeografyLocationDescription = txtGeografyLocationDescription.Text.Trim().ToUpper();
                objNodeDTO.i_NodeTypeId = Convert.ToInt32(ddlNodeType.SelectedValue);
                objNodeDTO.d_BeginDate  = dpBeginDate.SelectedDate.Value;
                objNodeDTO.d_EndDate    = dpEndDate.SelectedDate == null ? (DateTime?)null : dpEndDate.SelectedDate.Value;


                // Actualiza Nodo
                OperationResult objOperationResult1 = new OperationResult();
                _objNodeBL.UpdateNode(ref objOperationResult1, objNodeDTO, ((ClientSession)Session["objClientSession"]).GetAsList());

                if (objOperationResult1.Success != 1)
                {
                    Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult1.ExceptionMessage);
                }
            }

            // Cerrar página actual y hacer postback en el padre para actualizar
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }