public static supplierDto GetUpdateDMSDTO(Supplier supplier) { supplierDto dto = new supplierDto(); dto.suptCode = supplier.Code; dto.suptName = supplier.Name; dto.supShortName = supplier.ShortName; if (supplier.ContactObjectKey != null) { if (supplier.ContactObject.PersonName != null) { dto.linkMan = supplier.ContactObject.PersonName.DisplayName; } dto.phone = supplier.ContactObject.DefaultPhoneNum; dto.fax = supplier.ContactObject.DefaultFaxNum; if (supplier.ContactObject.DefaultLocation != null && supplier.ContactObject.DefaultLocation.PostalCode != null) { dto.zipCode = supplier.ContactObject.DefaultLocation.PostalCode.PostalCode; } if (supplier.ContactObject.DefaultLocation != null) { dto.address = supplier.ContactObject.DefaultLocation.Address1; } } dto.actionType = 2; // status 100201 有效 100202 无效 dto.status = (supplier.Effective != null && supplier.Effective.IsEffective) ? "100201" : "100202"; return(dto); }
public supplierDto GetSupplier(ref OperationResult pobjOperationResult, string pstrSupplierId) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); supplierDto objDtoEntity = null; var objEntity = (from a in dbContext.supplier where a.v_SupplierId == pstrSupplierId select a).FirstOrDefault(); if (objEntity != null) { objDtoEntity = supplierAssembler.ToDTO(objEntity); } pobjOperationResult.Success = 1; return(objDtoEntity); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); return(null); } }
public void AddSupplier(ref OperationResult pobjOperationResult, supplierDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); supplier objEntity = supplierAssembler.ToEntity(pobjDtoEntity); objEntity.d_InsertDate = DateTime.Now; objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]); objEntity.i_IsDeleted = 0; // Autogeneramos el Pk de la tabla int intNodeId = int.Parse(ClientSession[0]); NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 10), "SS");; objEntity.v_SupplierId = NewId; dbContext.AddTosupplier(objEntity); dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "PROVEEDOR", "v_SupplierId=" + NewId.ToString(), 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.CREACION, "PROVEEDOR", "v_SupplierId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
private void LoadData() { OperationResult objOperationResult = new OperationResult(); //Llenado de combos //Organization Utils.LoadDropDownList(ddlSectorTypeId, "Value1", "Id", BLL.Utils.GetDataHierarchyForCombo(ref objOperationResult, 104, null), DropDownListAction.Select); if (_Mode == "New") { // Additional logic here. } else if (_Mode == "Edit") { // Get the Entity Data _supplierDto = _objBL.GetSupplier(ref objOperationResult, _SupplierId); ddlSectorTypeId.SelectedValue = _supplierDto.i_SectorTypeId.ToString(); txtName.Text = _supplierDto.v_Name; txtIdentificationNumber.Text = _supplierDto.v_IdentificationNumber; txtAddress.Text = _supplierDto.v_Address; txtPhoneNumber.Text = _supplierDto.v_PhoneNumber; txtEmail.Text = _supplierDto.v_Mail; _Temp_IdentificationNumber = _supplierDto.v_IdentificationNumber; } }
private void btnSupplierSearch_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); frmSupplier frm = new frmSupplier("View"); frm.ShowDialog(); _SupplierId = frm._SupplierId; if (_SupplierId == null) { return; } SupplierBL objSupplierBL = new SupplierBL(); supplierDto objSupplierDto = new supplierDto(); objSupplierDto = objSupplierBL.GetSupplier(ref objOperationResult, _SupplierId); txtSupplier.Text = objSupplierDto.v_Name; }
public void Notify(params object[] args) { if (args != null && args.Length != 0 && args[0] is EntityEvent) { BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey; if (!(key == null)) { Supplier supplier = key.GetEntity() as Supplier; if (PubHelper.IsOrg_Supplier2DMS(supplier)) { bool flag = PubHelper.IsUsedDMSAPI(); if (flag) { if ( PubHelper.IsUpdateDMS(supplier) ) { try { PI08ImplService service = new PI08ImplService(); service.Url = PubHelper.GetAddress(service.Url); System.Collections.Generic.List <supplierDto> list = new System.Collections.Generic.List <supplierDto>(); supplierDto dto = GetUpdateDMSDTO(supplier); list.Add(dto); supplierDto s = service.Do(list.ToArray()); if (s != null && s.flag == 0) { throw new BusinessException(s.errMsg); } } catch (System.Exception e) { throw new BusinessException("调用DMS接口错误:" + e.Message); } } } } } } }
public void UpdateSupplier(ref OperationResult pobjOperationResult, supplierDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); // Obtener la entidad fuente var objEntitySource = (from a in dbContext.supplier where a.v_SupplierId == pobjDtoEntity.v_SupplierId select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); supplier objEntity = supplierAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.supplier.ApplyCurrentValues(objEntity); // Guardar los cambios dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "PROVEEDOR", "v_SupplierId=" + objEntity.v_SupplierId.ToString(), 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, "PROVEEDOR", "v_SupplierId=" + pobjDtoEntity.v_SupplierId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
public void Notify(params object[] args) { if (args != null && args.Length != 0 && args[0] is EntityEvent) { BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey; if (!(key == null)) { Supplier supplier = key.GetEntity() as Supplier; if (PubHelper.IsOrg_Supplier2DMS(supplier)) { bool flag = PubHelper.IsUsedDMSAPI(); if (flag) { if (PubHelper.IsUpdateDMS(supplier) ) { try { PI08ImplService service = new PI08ImplService(); // service.Url = PubHelper.GetAddress(service.Url); supplierDto dto = new supplierDto(); System.Collections.Generic.List <supplierDto> list = new System.Collections.Generic.List <supplierDto>(); dto.suptCode = supplier.Code; dto.suptName = supplier.Name; dto.supShortName = supplier.ShortName; if (supplier.ContactObjectKey != null) { if (supplier.ContactObject.PersonName != null) { dto.linkMan = supplier.ContactObject.PersonName.DisplayName; } dto.phone = supplier.ContactObject.DefaultPhoneNum; dto.fax = supplier.ContactObject.DefaultFaxNum; if (supplier.ContactObject.DefaultLocation != null && supplier.ContactObject.DefaultLocation.PostalCode != null) { dto.zipCode = supplier.ContactObject.DefaultLocation.PostalCode.PostalCode; } if (supplier.ContactObject.DefaultLocation != null) { dto.address = supplier.ContactObject.DefaultLocation.Address1; } } dto.actionType = 1; // status 100201 有效 100202 无效 dto.status = (supplier.Effective != null && supplier.Effective.IsEffective) ? "100201" : "100202"; list.Add(dto); supplierDto s = service.Do(list.ToArray()); if (s != null && s.flag == 0) { throw new BusinessException(s.errMsg); } } catch (System.Exception e) { throw new BusinessException("调用DMS接口错误:" + e.Message); } } } } } } }
private void LoadData() { OperationResult objOperationResult = new OperationResult(); Utils.LoadDropDownList(ddlProductId, "Value1", "Id", BLL.Utils.GetProductWarehouse(ref objOperationResult, "Id==" + "\"" + -1 + "\""), DropDownListAction.Select); // el combo producto se carga vacio hasta que se seleccione un almacén de origen. lblNodeSource.Text = Globals.ClientSession.v_CurrentExecutionNodeName; dtpDate.CustomFormat = "dd/MM/yyyy"; if (_Mode == "New") { _booAlreadySaved = false; //Source Utils.LoadDropDownList(ddlOrganizationLocationSourceId, "Value1", "Id", BLL.Utils.GetJoinOrganizationAndLocationNotInRestricted(ref objOperationResult, Globals.ClientSession.i_CurrentExecutionNodeId), DropDownListAction.Select); Utils.LoadDropDownList(ddlWarehouseSourceId, "Value1", "Id", BLL.Utils.GetWarehouseNotInRestricted(ref objOperationResult, Globals.ClientSession.i_CurrentExecutionNodeId, "-1", "-1"), DropDownListAction.Select); //Destination Utils.LoadDropDownList(ddlNodeDestinationId, "Value1", "Id", BLL.Utils.GetAllNodeForCombo(ref objOperationResult), DropDownListAction.Select); if (rbLocal.Checked == true) { ddlNodeDestinationId.Enabled = false; ddlNodeDestinationId.SelectedValue = Globals.ClientSession.i_CurrentExecutionNodeId.ToString(); } else { ddlNodeDestinationId.Enabled = true; } Utils.LoadDropDownList(ddlOrganizationLocationDestinationId, "Value1", "Id", BLL.Utils.GetJoinOrganizationAndLocationNotInRestricted(ref objOperationResult, Globals.ClientSession.i_CurrentExecutionNodeId), DropDownListAction.Select); Utils.LoadDropDownList(ddlWarehouseDestinationId, "Value1", "Id", BLL.Utils.GetWarehouseNotInRestricted(ref objOperationResult, Globals.ClientSession.i_CurrentExecutionNodeId, "-1", "-1"), DropDownListAction.Select); txtIsProcessed.Text = "NO"; txtDocReference.Text = ""; dtpDate.Value = DateTime.Now.Date; } else if (_Mode == "Edit") { // Get the Entity Data warehouseDto objwarehouseDto = new warehouseDto(); WarehouseBL objWarehouseBL = new WarehouseBL(); movementDto objMovementDto = new movementDto(); MovementBL objMovementBL = new MovementBL(); movementdetailDto objmovementdetailDto = new movementdetailDto(); supplierDto objSupplierDto = new supplierDto(); SupplierBL objSupplierBL = new SupplierBL(); nodeorganizationlocationwarehouseprofileDto objnodeorganizationlocationwarehouseprofileDto = new nodeorganizationlocationwarehouseprofileDto(); NodeBL objNodeBL = new NodeBL(); _booAlreadySaved = true; string pstrFilterExpression = null; objMovementDto = objMovementBL.GetMovement(ref objOperationResult, _MovementId); //Source Utils.LoadDropDownList(ddlOrganizationLocationSourceId, "Value1", "Id", BLL.Utils.GetJoinOrganizationAndLocationNotInRestricted(ref objOperationResult, Globals.ClientSession.i_CurrentExecutionNodeId), DropDownListAction.Select); objwarehouseDto = objWarehouseBL.GetWarehouse(ref objOperationResult, objMovementDto.v_WarehouseId); ddlOrganizationLocationSourceId.SelectedValue = Globals.ClientSession.i_CurrentExecutionNodeId + "|" + objwarehouseDto.v_OrganizationId + "|" + objwarehouseDto.v_LocationId; ddlWarehouseSourceId.SelectedValue = objwarehouseDto.v_WarehouseId; //Destination Utils.LoadDropDownList(ddlNodeDestinationId, "Value1", "Id", BLL.Utils.GetAllNodeForCombo(ref objOperationResult), DropDownListAction.Select); objnodeorganizationlocationwarehouseprofileDto = objNodeBL.GetNodeOrganizationLocationWarehouseProfile(ref objOperationResult, objMovementDto.v_RemoteWarehouseId); if (Globals.ClientSession.i_CurrentExecutionNodeId.ToString() == objnodeorganizationlocationwarehouseprofileDto.i_NodeId.ToString()) { ddlNodeDestinationId.Enabled = false; rbLocal.Checked = true; } else { ddlNodeDestinationId.Enabled = true; rbRemote.Checked = true; } ddlNodeDestinationId.SelectedValue = objnodeorganizationlocationwarehouseprofileDto.i_NodeId.ToString(); ddlOrganizationLocationDestinationId.SelectedValue = objnodeorganizationlocationwarehouseprofileDto.i_NodeId.ToString() + "|" + objnodeorganizationlocationwarehouseprofileDto.v_OrganizationId + "|" + objnodeorganizationlocationwarehouseprofileDto.v_LocationId; ddlWarehouseDestinationId.SelectedValue = objMovementDto.v_RemoteWarehouseId; txtDocReference.Text = objMovementDto.v_ReferenceDocument; dtpDate.Value = (DateTime)objMovementDto.d_Date; if (objMovementDto.i_IsLocallyProcessed == (int)Common.SiNo.NO) { txtIsProcessed.Text = "NO"; btnSaveRefresh.Enabled = true; btnConfirmProcess.Enabled = true; btnDiscardProcess.Enabled = true; } else { txtIsProcessed.Text = "SI"; btnSaveRefresh.Enabled = false; btnConfirmProcess.Enabled = false; btnDiscardProcess.Enabled = false; } pstrFilterExpression = "v_MovementId==" + "\"" + objMovementDto.v_MovementId + "\"" + "&&" + "v_WarehouseId==" + "\"" + objMovementDto.v_WarehouseId + "\""; _TempMovementDetailList = objMovementBL.GetMovementDeatilPagedAndFiltered(ref objOperationResult, 0, null, "", pstrFilterExpression); lblRecordCount.Text = string.Format("Se encontraron {0} registros.", _TempMovementDetailList.Count()); grdData.DataSource = _TempMovementDetailList; } }
private void btnOK_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); string pstrFilterEpression; if (uvOrganization.Validate(true, false).IsValid) { if (txtIdentificationNumber.Text.Trim() == "") { MessageBox.Show("Por favor ingrese un nombre apropiado para la Nro Identificación.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txtName.Text.Trim() == "") { MessageBox.Show("Por favor ingrese un nombre apropiado para la Razón Social.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if (!Common.Utils.ValidateIdentificationDocumentPeru(txtIdentificationNumber.Text)) //{ // MessageBox.Show("El Nro. identificación es errado .", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} if (_Mode == "New") { _supplierDto = new supplierDto(); // Populate the entity _supplierDto.i_SectorTypeId = int.Parse(ddlSectorTypeId.SelectedValue.ToString()); _supplierDto.v_IdentificationNumber = txtIdentificationNumber.Text.Trim(); _supplierDto.v_Name = txtName.Text.Trim(); _supplierDto.v_Address = txtAddress.Text.Trim(); _supplierDto.v_PhoneNumber = txtPhoneNumber.Text.Trim(); _supplierDto.v_Mail = txtEmail.Text.Trim(); pstrFilterEpression = "i_IsDeleted==0 && v_IdentificationNumber==(\"" + txtIdentificationNumber.Text.Trim() + "\")"; if (_objBL.GetSuppliersPagedAndFiltered(ref objOperationResult, null, null, null, pstrFilterEpression).Count() != 0) { MessageBox.Show("El Nro. Identificación ya existe:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { // Save the data _objBL.AddSupplier(ref objOperationResult, _supplierDto, Globals.ClientSession.GetAsList()); } } else if (_Mode == "Edit") { // Populate the entity _supplierDto.v_SupplierId = _SupplierId; _supplierDto.i_SectorTypeId = int.Parse(ddlSectorTypeId.SelectedValue.ToString()); _supplierDto.v_IdentificationNumber = txtIdentificationNumber.Text.Trim(); _supplierDto.v_Name = txtName.Text.Trim(); _supplierDto.v_Address = txtAddress.Text.Trim(); _supplierDto.v_PhoneNumber = txtPhoneNumber.Text.Trim(); _supplierDto.v_Mail = txtEmail.Text.Trim(); if (_Temp_IdentificationNumber == _supplierDto.v_IdentificationNumber) { // Save the data _objBL.UpdateSupplier(ref objOperationResult, _supplierDto, Globals.ClientSession.GetAsList()); } else { pstrFilterEpression = "i_IsDeleted==0 && v_IdentificationNumber==(\"" + txtIdentificationNumber.Text.Trim() + "\")"; if (_objBL.GetSuppliersPagedAndFiltered(ref objOperationResult, null, null, null, pstrFilterEpression).Count() != 0) { MessageBox.Show("El Nro Identificación ya existe:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { // Save the data _objBL.UpdateSupplier(ref objOperationResult, _supplierDto, Globals.ClientSession.GetAsList()); } } } //// Analizar el resultado de la operación if (objOperationResult.Success == 1) // Operación sin error { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else // Operación con error { MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); // Se queda en el formulario. } } else { MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void LoadData() { OperationResult objOperationResult = new OperationResult(); var objData1 = BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 110, ""); // Motivos de Ingreso // Remover el elemento TRANSFERENCIA ENTRE ALMACENES var objData1List = objData1.ToList(); objData1List.RemoveAll(item => Int32.Parse(item.Id) < 11); objData1List.RemoveAll(item => Int32.Parse(item.Id) > 18); //// Llenar el combo de Motivos Utils.LoadDropDownList(ddlMotiveId, "Value1", "Id", objData1List, DropDownListAction.Select); Utils.LoadDropDownList(ddlProductId, "Value1", "Id", BLL.Utils.GetProductWarehouse(ref objOperationResult, "Value2==" + "\"" + _WarehouseId + "\""), DropDownListAction.Select); if (_Mode == "New") { txtIsProcessed.Text = "NO"; txtDocReference.Text = ""; dtpDate.Value = DateTime.Now.Date; _booAlreadySaved = false; } else if (_Mode == "Edit") { // Get the Entity Data movementDto objMovementDto = new movementDto(); MovementBL objMovementBL = new MovementBL(); movementdetailDto objmovementdetailDto = new movementdetailDto(); supplierDto objSupplierDto = new supplierDto(); SupplierBL objSupplierBL = new SupplierBL(); string pstrFilterExpression = null; objMovementDto = objMovementBL.GetMovement(ref objOperationResult, _MovementId); ddlMotiveId.SelectedValue = objMovementDto.i_MotiveTypeId.ToString(); txtDocReference.Text = objMovementDto.v_ReferenceDocument; dtpDate.Value = (DateTime)objMovementDto.d_Date; if (objMovementDto.i_IsLocallyProcessed == (int)Common.SiNo.NO) { txtIsProcessed.Text = "NO"; btnSaveRefresh.Enabled = true; btnConfirmProcess.Enabled = true; btnDiscardProcess.Enabled = true; } else { txtIsProcessed.Text = "SI"; btnSaveRefresh.Enabled = false; btnConfirmProcess.Enabled = false; btnDiscardProcess.Enabled = false; groupBox1.Enabled = false; groupBox2.Enabled = false; } pstrFilterExpression = "v_MovementId==" + "\"" + objMovementDto.v_MovementId + "\"" + "&&" + "v_WarehouseId==" + "\"" + objMovementDto.v_WarehouseId + "\""; _TempMovementDetailList = objMovementBL.GetMovementDeatilPagedAndFiltered(ref objOperationResult, 0, null, "", pstrFilterExpression); lblRecordCount.Text = string.Format("Se encontraron {0} registros.", _TempMovementDetailList.Count()); grdData.DataSource = _TempMovementDetailList; _booAlreadySaved = true; } }