예제 #1
0
        public void AddDataHierarchy(ref OperationResult pobjOperationResult, datahierarchyDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                datahierarchy         objEntity = datahierarchyAssembler.ToEntity(pobjDtoEntity);


                objEntity.d_InsertDate   = DateTime.Now;
                objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                objEntity.i_IsDeleted    = 0;

                dbContext.AddTodatahierarchy(objEntity);
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "DATA HIERARCHY", "GroupId=" + objEntity.i_GroupId.ToString() + " / Descripción = " + objEntity.v_Value1, Success.Ok, null);

                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = ex.Message;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "DATA HIERARCHY", "GroupId=" + pobjDtoEntity.i_GroupId.ToString() + " / Descripción = " + pobjDtoEntity.v_Value1, Success.Failed, ex.Message);
                return;
            }
        }
예제 #2
0
        public datahierarchyDto GetDataHierarchy(ref OperationResult pobjOperationResult, int pintGroupId, int pintParameterId)
        {
            //mon.IsActive = true;

            try
            {
                SigesoftEntitiesModel dbContext    = new SigesoftEntitiesModel();
                datahierarchyDto      objDtoEntity = null;

                var objEntity = (from a in dbContext.datahierarchy
                                 where a.i_GroupId == pintGroupId && a.i_ItemId == pintParameterId
                                 select a).FirstOrDefault();

                if (objEntity != null)
                {
                    objDtoEntity = datahierarchyAssembler.ToDTO(objEntity);
                }

                pobjOperationResult.Success = 1;
                return(objDtoEntity);
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = ex.Message;
                return(null);
            }
        }
예제 #3
0
        private void ddlDocTypeId_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlDocTypeId.Text == "--Seleccionar--")
            {
                return;
            }

            OperationResult  objOperationResult  = new OperationResult();
            DataHierarchyBL  objDataHierarchyBL  = new DataHierarchyBL();
            datahierarchyDto objDataHierarchyDto = new datahierarchyDto();

            int value = Int32.Parse(ddlDocTypeId.SelectedValue.ToString());

            objDataHierarchyDto    = objDataHierarchyBL.GetDataHierarchy(ref objOperationResult, 106, value);
            txtDocNumber.MaxLength = Int32.Parse(objDataHierarchyDto.v_Value2);
        }
예제 #4
0
        private void LoadData()
        {
            OperationResult objOperationResult = new OperationResult();
            //Llenado de combos
            Utils UtilComboBox = new Utils();

            string Mode = Request.QueryString["Mode"].ToString();
            int    GroupId = -1, ItemId = -1;

            if (Request.QueryString["i_GroupId"] != null)
            {
                GroupId = int.Parse(Request.QueryString["i_GroupId"].ToString());
            }

            if (Request.QueryString["i_ItemId"] != null)
            {
                ItemId = int.Parse(Request.QueryString["i_ItemId"].ToString());
            }
            ViewState["ItemId"] = ItemId;
            ViewState["strFilterExpression"] = null;

            if (Mode == "Edit")
            {
                // Bloquear algunos campos

                txtParameterId.Enabled = false;
                txtDescription.Enabled = false;
                // Get the Entity Data
                datahierarchyDto objEntity = _objBL.GetDataHierarchy(ref objOperationResult, GroupId, ItemId);

                // Save the entity on the session
                Session["objEntity"] = objEntity;

                // Show the data on the form
                txtParameterId.Text = objEntity.i_ItemId.ToString();
                txtDescription.Text = objEntity.v_Value1;

                BindGrid();
            }
        }
예제 #5
0
        public void UpdateDataHierarchy(ref OperationResult pobjOperationResult, datahierarchyDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();

                // Obtener la entidad fuente
                var objEntitySource = (from a in dbContext.datahierarchy
                                       where a.i_GroupId == pobjDtoEntity.i_GroupId && a.i_ItemId == pobjDtoEntity.i_ItemId
                                       select a).FirstOrDefault();

                // Crear la entidad con los datos actualizados
                pobjDtoEntity.d_UpdateDate   = DateTime.Now;
                pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                datahierarchy objEntity = datahierarchyAssembler.ToEntity(pobjDtoEntity);

                // Copiar los valores desde la entidad actualizada a la Entidad Fuente
                dbContext.datahierarchy.ApplyCurrentValues(objEntity);

                // Guardar los cambios
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;

                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "DATA HIERARCHY", "GroupId=" + objEntity.i_GroupId.ToString() + " / Descripción = " + objEntity.v_Value1, Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = ex.Message;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "DATA HIERARCHY", "GroupId=" + pobjDtoEntity.i_GroupId.ToString() + " / Descripción = " + pobjDtoEntity.v_Value1, Success.Failed, ex.Message);
                return;
            }
        }
예제 #6
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            string          Mode = Request.QueryString["Mode"].ToString();
            OperationResult objOperationResult = new OperationResult();

            if (Mode == "New")
            {
                // Create the entity
                datahierarchyDto objEntity = new datahierarchyDto();

                // Populate the entity
                objEntity.i_GroupId      = int.Parse(txtGroupId.Text.Trim());
                objEntity.i_ItemId       = int.Parse(txtParameterId.Text.Trim());
                objEntity.v_Value1       = txtDescription.Text.Trim().ToUpper();
                objEntity.v_Value2       = txtDescription2.Text.Trim().ToUpper();
                objEntity.v_Field        = txtField.Text.Trim().ToUpper();
                objEntity.i_ParentItemId = -1;

                // Obtener el usuario autenticado
                int intUserPersonId = ((ClientSession)Session["objClientSession"]).i_SystemUserId;
                //Validar si la Clave primaria ya existe.
                if (_objBL.GetDataHierarchy(ref objOperationResult, objEntity.i_GroupId, objEntity.i_ItemId) != null)
                {
                    Alert.Show("La clave primaria ya existe!", MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    // Save the data
                    _objBL.AddDataHierarchy(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
                }
            }
            else if (Mode == "Edit")
            {
                // Obtener el usuario autenticado
                int intUserPersonId = ((ClientSession)Session["objClientSession"]).i_SystemUserId;

                // Get the entity from the session
                datahierarchyDto objEntity = (datahierarchyDto)Session["objEntity"];

                // Populate the entity
                objEntity.i_GroupId = int.Parse(txtGroupId.Text.Trim());
                objEntity.i_ItemId  = int.Parse(txtParameterId.Text.Trim());
                objEntity.v_Value1  = txtDescription.Text.Trim().ToUpper();
                if (txtUserInterfaceOrder.Text == "")
                {
                    objEntity.i_Sort = null;
                }
                else
                {
                    objEntity.i_Sort = int.Parse(txtUserInterfaceOrder.Text.Trim());
                }
                objEntity.v_Value2       = txtDescription2.Text.Trim().ToUpper();
                objEntity.v_Field        = txtField.Text.Trim().ToUpper();
                objEntity.i_ParentItemId = Int32.Parse(ddlParentItemId.SelectedValue);

                // Save the data
                _objBL.UpdateDataHierarchy(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
            }
            else if (Mode == "NewChildren")
            {
                // Obtener el usuario autenticado
                //int intUserPersonId = ((ClientSession)Session["objClientSession"]).i_SystemUserId;

                // Create the entity
                datahierarchyDto objEntity = new datahierarchyDto();

                // Populate the entity
                objEntity.i_GroupId = int.Parse(txtGroupId.Text.Trim());
                objEntity.i_ItemId  = int.Parse(txtParameterId.Text.Trim());
                objEntity.v_Value1  = txtDescription.Text.Trim().ToUpper();
                if (txtUserInterfaceOrder.Text == "")
                {
                    objEntity.i_Sort = null;
                }
                else
                {
                    objEntity.i_Sort = int.Parse(txtUserInterfaceOrder.Text.Trim());
                }
                objEntity.v_Value2       = txtDescription2.Text.Trim().ToUpper();
                objEntity.v_Field        = txtField.Text.Trim().ToUpper();
                objEntity.i_ParentItemId = Int32.Parse(ddlParentItemId.SelectedValue);

                if (_objBL.GetDataHierarchy(ref objOperationResult, objEntity.i_GroupId, objEntity.i_ItemId) != null)
                {
                    Alert.Show("¡La clave primaria ya existe!", MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    // Save the data
                    _objBL.AddDataHierarchy(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
                }
            }
            //Analizar el resultado de la operación
            if (objOperationResult.Success == 1)  // Operación sin error
            {
                // Cerrar página actual y hacer postback en el padre para actualizar
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else  // Operación con error
            {
                Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage);
                // Se queda en el formulario.
            }
        }
예제 #7
0
        private void LoadData()
        {
            OperationResult objOperationResult = new OperationResult();

            string Mode = Request.QueryString["Mode"].ToString();
            int    GroupId = -1, ParameterId = -1;

            if (Request.QueryString["i_GroupId"] != null)
            {
                GroupId = int.Parse(Request.QueryString["i_GroupId"].ToString());
            }
            if (Request.QueryString["i_ItemId"] != null)
            {
                ParameterId = int.Parse(Request.QueryString["i_ItemId"].ToString());
            }

            //Llenar combo ItemParameter Tree
            ddlParentItemId.DataTextField              = "Description";
            ddlParentItemId.DataValueField             = "Id";
            ddlParentItemId.DataSimulateTreeLevelField = "Level";
            ddlParentItemId.DataEnableSelectField      = "EnabledSelect";
            List <DataForTreeView> t = _objBL.GetDataHierarchyForCombo(ref objOperationResult, GroupId).ToList();

            ddlParentItemId.DataSource = t;
            ddlParentItemId.DataBind();
            this.ddlParentItemId.Items.Insert(0, new FineUI.ListItem("-- Seleccione --", "-1"));

            if (Mode == "New")
            {
                // Additional logic here.
                txtGroupId.Enabled      = false;
                txtGroupId.Text         = "0";
                ddlParentItemId.Enabled = false;
            }
            else if (Mode == "Edit")
            {
                // Bloquear algunos campos
                txtGroupId.Enabled      = false;
                txtParameterId.Enabled  = false;
                ddlParentItemId.Enabled = true;

                // Get the Entity Data
                datahierarchyDto objEntity = _objBL.GetDataHierarchy(ref objOperationResult, GroupId, ParameterId);

                // Save the entity on the session
                Session["objEntity"] = objEntity;

                // Show the data on the form
                txtGroupId.Text      = objEntity.i_GroupId.ToString();
                txtParameterId.Text  = objEntity.i_ItemId.ToString();
                txtDescription.Text  = objEntity.v_Value1;
                txtDescription2.Text = objEntity.v_Value2;
                if (objEntity.i_Sort.HasValue)
                {
                    txtUserInterfaceOrder.Text = objEntity.i_Sort.Value.ToString();
                }
                txtField.Text = objEntity.v_Field;
                ddlParentItemId.SelectedValue = objEntity.i_ParentItemId.ToString();

                if (GroupId == 0)
                {
                    ddlParentItemId.Enabled = false;
                }
            }
            if (Mode == "NewChildren")
            {
                txtGroupId.Text    = GroupId.ToString();
                txtGroupId.Enabled = false;
                txtParameterId.Focus();
            }
        }
예제 #8
0
        private void btnFilter_Click(object sender, EventArgs e)
        {
            string strCadena = null;

            strFilterExpression = null;
            OperationResult          objOperationResult  = new OperationResult();
            DataHierarchyBL          objDataHierarchyBL  = new DataHierarchyBL();
            datahierarchyDto         objdatahierarchyDto = new datahierarchyDto();
            List <DataHierarchyList> DataHierarchyList   = new List <DataHierarchyList>();

            string selectedItemddlCodicionStock = ddlCodicionStock.Items[ddlCodicionStock.SelectedIndex].ToString();

            if (ultraValidator1.Validate(true, false).IsValid)
            {
                // Get the filters from the UI
                List <string> Filters = new List <string>();
                if (!string.IsNullOrEmpty(txtName.Text))
                {
                    Filters.Add("(v_ProductName.Contains(\"" + txtName.Text.Trim() + "\"))");
                }
                if (ddlCategoryId.Text != "--Todos--")
                {
                    int idCategory = Convert.ToInt32(ddlCategoryId.SelectedNode.Tag);
                    objdatahierarchyDto = objDataHierarchyBL.GetDataHierarchy(ref objOperationResult, 103, idCategory);

                    DataHierarchyList = objDataHierarchyBL.GetDataHierarchies(ref objOperationResult, 103, objdatahierarchyDto.i_ItemId);

                    if (DataHierarchyList.Count == 0)
                    {
                        strCadena = "i_CategoryId==" + ddlCategoryId.SelectedNode.Tag + " || ";
                    }
                    else
                    {
                        foreach (var item in DataHierarchyList)
                        {
                            strCadena = strCadena + "i_CategoryId==" + item.i_ItemId + " || ";
                        }
                    }

                    if (strCadena != null)
                    {
                        strCadena = strCadena.Substring(0, strCadena.Length - 4);
                        Filters.Add("(" + strCadena + ")");
                    }
                }
                if (ddlware.SelectedValue.ToString() != "-1")
                {
                    Filters.Add("v_WarehouseId==" + "\"" + ddlware.SelectedValue + "\"");
                }
                if (!string.IsNullOrEmpty(txtBrand.Text))
                {
                    Filters.Add("v_Brand.Contains(\"" + txtBrand.Text.Trim() + "\")");
                }
                if (!string.IsNullOrEmpty(txtSerialNumber.Text))
                {
                    Filters.Add("v_SerialNumber.Contains(\"" + txtSerialNumber.Text.Trim() + "\")");
                }
                if (ddlCodicionStock.SelectedIndex == 1)
                {
                    Filters.Add("r_StockActual < r_StockMin ");
                }
                else if (ddlCodicionStock.SelectedIndex == 2)
                {
                    Filters.Add("r_StockActual > r_StockMax ");
                }
                //// Create the Filter Expression
                if (Filters.Count > 0)
                {
                    foreach (string item in Filters)
                    {
                        strFilterExpression = strFilterExpression + item + " && ";
                    }
                    strFilterExpression = strFilterExpression.Substring(0, strFilterExpression.Length - 4);
                }
                this.BindGrid();
            }
            else
            {
                MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }