protected void btnSaveRefresh_Click(object sender, EventArgs e) { var locationId = ""; string Mode = Request.QueryString["Mode"].ToString(); OperationResult objOperationResult = new OperationResult(); if (Mode == "New") { // Create the entity locationDto objEntity = new locationDto(); // Populate the entity objEntity.v_OrganizationId = Session["v_OrganizationId"].ToString(); objEntity.v_Name = txtSede.Text; // Save the data locationId = oOrganizationBL.AddLocation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList()); //Rutina para Asignar la Empresa creada automaticamente al nodo actual NodeOrganizationLoactionWarehouseList objNodeOrganizationLoactionWarehouseList = new NodeOrganizationLoactionWarehouseList(); List <nodeorganizationlocationwarehouseprofileDto> objnodeorganizationlocationwarehouseprofileDto = new List <nodeorganizationlocationwarehouseprofileDto>(); //Llenar Entidad Empresa/sede objNodeOrganizationLoactionWarehouseList.i_NodeId = 9; objNodeOrganizationLoactionWarehouseList.v_OrganizationId = Session["v_OrganizationId"].ToString(); objNodeOrganizationLoactionWarehouseList.v_LocationId = locationId; //Llenar Entidad Almacén var objInsertWarehouseList = InsertWarehouse(locationId); oOrganizationBL.AddNodeOrganizationLoactionWarehouse(ref objOperationResult, objNodeOrganizationLoactionWarehouseList, objInsertWarehouseList, ((ClientSession)Session["objClientSession"]).GetAsList()); } else if (Mode == "Edit") { locationDto objEntity = new locationDto(); // Populate the entity objEntity.v_OrganizationId = Session["v_OrganizationId"].ToString(); objEntity.v_LocationId = Session["v_LocationId"].ToString(); objEntity.v_Name = txtSede.Text; oOrganizationBL.UpdateLocation(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. } }
public void AddNodeOrganizationLoactionWarehouse(ref OperationResult pobjOperationResult, NodeOrganizationLoactionWarehouseList pobjNodeOrgLocationWarehouse, List <nodeorganizationlocationwarehouseprofileDto> pobjWarehouseList, List <string> ClientSession) { //mon.IsActive = true; nodeorganizationprofile objNodeorganizationprofile = new nodeorganizationprofile(); nodeorganizationlocationprofile objNodeorganizationlocationprofile = new nodeorganizationlocationprofile(); try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); OperationResult objOperationResult5 = new OperationResult(); if (pobjWarehouseList != null) { if (IsWarehouseAssignedToNode(ref objOperationResult5, pobjWarehouseList)) { pobjOperationResult = objOperationResult5; return; } } var objEntitySource = (from a in dbContext.nodeorganizationlocationprofile join c in dbContext.nodeorganizationlocationprofile on a.i_NodeId equals c.i_NodeId where a.i_NodeId == pobjNodeOrgLocationWarehouse.i_NodeId && a.v_OrganizationId == pobjNodeOrgLocationWarehouse.v_OrganizationId && c.v_LocationId == pobjNodeOrgLocationWarehouse.v_LocationId select a).FirstOrDefault(); if (objEntitySource != null) { // Actualizar registro (dar de alta al registro ya existente "no volver a insertar") OperationResult objOperationResult2 = new OperationResult(); UpdateNodeOrganizationChangeStatusAll(ref objOperationResult2, pobjNodeOrgLocationWarehouse.i_NodeId, pobjNodeOrgLocationWarehouse.v_OrganizationId, pobjNodeOrgLocationWarehouse.v_LocationId, 0, ClientSession); pobjOperationResult = objOperationResult2; } else { var query = (from a in dbContext.nodeorganizationlocationprofile where a.i_NodeId == pobjNodeOrgLocationWarehouse.i_NodeId && a.v_OrganizationId == pobjNodeOrgLocationWarehouse.v_OrganizationId select a).FirstOrDefault(); // Grabar nuevo if (query == null) { #region Nodeorganization // Grabar nodo / empresa objNodeorganizationprofile.d_InsertDate = DateTime.Now; objNodeorganizationprofile.i_InsertUserId = Int32.Parse(ClientSession[2]); objNodeorganizationprofile.i_IsDeleted = 0; objNodeorganizationprofile.i_NodeId = pobjNodeOrgLocationWarehouse.i_NodeId; objNodeorganizationprofile.v_OrganizationId = pobjNodeOrgLocationWarehouse.v_OrganizationId; dbContext.AddTonodeorganizationprofile(objNodeorganizationprofile); dbContext.SaveChanges(); #endregion #region Nodeorganizationlocation // Grabar nodo / empresa / sede objNodeorganizationlocationprofile.d_InsertDate = DateTime.Now; objNodeorganizationlocationprofile.i_InsertUserId = Int32.Parse(ClientSession[2]); objNodeorganizationlocationprofile.i_IsDeleted = 0; objNodeorganizationlocationprofile.i_NodeId = pobjNodeOrgLocationWarehouse.i_NodeId; objNodeorganizationlocationprofile.v_OrganizationId = pobjNodeOrgLocationWarehouse.v_OrganizationId; objNodeorganizationlocationprofile.v_LocationId = pobjNodeOrgLocationWarehouse.v_LocationId; dbContext.AddTonodeorganizationlocationprofile(objNodeorganizationlocationprofile); dbContext.SaveChanges(); #endregion #region Add Warehouse // Graba almacenes OperationResult objOperationResult1 = new OperationResult(); if (pobjWarehouseList != null) { AddWarehouse(ref objOperationResult1, pobjWarehouseList, ClientSession); } #endregion } else { #region Nodeorganizationlocation // Grabar nodo / empresa / sede objNodeorganizationlocationprofile.d_InsertDate = DateTime.Now; objNodeorganizationlocationprofile.i_InsertUserId = Int32.Parse(ClientSession[2]); objNodeorganizationlocationprofile.i_IsDeleted = 0; objNodeorganizationlocationprofile.i_NodeId = pobjNodeOrgLocationWarehouse.i_NodeId; objNodeorganizationlocationprofile.v_OrganizationId = pobjNodeOrgLocationWarehouse.v_OrganizationId; objNodeorganizationlocationprofile.v_LocationId = pobjNodeOrgLocationWarehouse.v_LocationId; dbContext.AddTonodeorganizationlocationprofile(objNodeorganizationlocationprofile); dbContext.SaveChanges(); #endregion #region Add Warehouse // Graba almacenes OperationResult objOperationResult1 = new OperationResult(); if (pobjWarehouseList != null) { AddWarehouse(ref objOperationResult1, pobjWarehouseList, ClientSession); } #endregion } } pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EMPRESA / SEDE / ALMACÉN", "v_OrganizationId=" + objNodeorganizationprofile.v_OrganizationId, Success.Ok, null); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EMPRESA / SEDE / ALMACÉN", "v_OrganizationId=" + objNodeorganizationprofile.v_OrganizationId, Success.Failed, pobjOperationResult.ExceptionMessage); } }
public void UpdateNodeOrganizationLoactionWarehouse(ref OperationResult pobjOperationResult, NodeOrganizationLoactionWarehouseList pobjNodeOrgLocationWarehouse, List <nodeorganizationlocationwarehouseprofileDto> pobjWarehouseListAdd, List <nodeorganizationlocationwarehouseprofileDto> pobjWarehouseListDel, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); #region Warehouse -> Add / Del // Eliminar Almacenes if (pobjWarehouseListDel != null) { OperationResult objOperationResult1 = new OperationResult(); DeleteWarehouse(ref objOperationResult1, pobjWarehouseListDel, ClientSession); } // Graba almacenes if (pobjWarehouseListAdd != null) { OperationResult objOperationResult3 = new OperationResult(); if (IsWarehouseAssignedToNode(ref objOperationResult3, pobjWarehouseListAdd)) { pobjOperationResult = objOperationResult3; return; } OperationResult objOperationResult2 = new OperationResult(); AddWarehouse(ref objOperationResult2, pobjWarehouseListAdd, ClientSession); } #endregion pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "EMPRESA / SEDE / ALMACÉN", "v_OrganizationId=" + pobjNodeOrgLocationWarehouse.v_OrganizationId, Success.Ok, null); return; } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "EMPRESA / SEDE / ALMACÉN", "v_OrganizationId=" + pobjNodeOrgLocationWarehouse.v_OrganizationId, Success.Failed, pobjOperationResult.ExceptionMessage); } }
protected void btnSaveRefresh_Click(object sender, EventArgs e) { if (Mode == "New") { #region Validate #endregion // Datos de nodo / Empresa / Sede NodeOrganizationLoactionWarehouseList objNodeOrgLocaWarehouse = new NodeOrganizationLoactionWarehouseList(); objNodeOrgLocaWarehouse.i_NodeId = NodeId; objNodeOrgLocaWarehouse.v_OrganizationId = ddlOrganization.SelectedValue; objNodeOrgLocaWarehouse.v_LocationId = ddlLocation.SelectedValue; // Datos de Almacén var objInsertWarehouseList = InsertWarehouse(); OperationResult objOperationResult1 = new OperationResult(); // Graba Nodo / Empresa / Sede / Almacén _objNodeBL.AddNodeOrganizationLoactionWarehouse(ref objOperationResult1, objNodeOrgLocaWarehouse, objInsertWarehouseList, ((ClientSession)Session["objClientSession"]).GetAsList()); if (objOperationResult1.ErrorMessage != null) { Alert.ShowInTop(objOperationResult1.ErrorMessage); return; } if (objOperationResult1.Success != 1) { Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult1.ExceptionMessage); } } else if (Mode == "Edit") { NodeOrganizationLoactionWarehouseList objNodeOrgLocaWarehouse = new NodeOrganizationLoactionWarehouseList(); objNodeOrgLocaWarehouse.i_NodeId = NodeId; objNodeOrgLocaWarehouse.v_OrganizationId = ddlOrganization.SelectedValue; objNodeOrgLocaWarehouse.v_LocationId = ddlLocation.SelectedValue; OperationResult objOperationResult2 = new OperationResult(); var objAddWarehouseList = UpdateWarehouse(); var objDeleteWarehouseList = DeleteWarehouse(); _objNodeBL.UpdateNodeOrganizationLoactionWarehouse(ref objOperationResult2, objNodeOrgLocaWarehouse, objAddWarehouseList, objDeleteWarehouseList, ((ClientSession)Session["objClientSession"]).GetAsList()); if (objOperationResult2.ErrorMessage != null) { Alert.ShowInTop(objOperationResult2.ErrorMessage); return; } } // Cerrar página actual y hacer postback en el padre para actualizar PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }