/// <summary> /// Actualiza los datos en la tabla de la base de datos /// </summary> public void Actualizar() { CAE cae; string numeroRegistro; //Actualizar data source matriz.FlushToDataSource(); //Crear nueva instanacia del mantenimiento de tipos de documentos a conservar ManteUdoDocCon manteUdoDocCon = new ManteUdoDocCon(); //Obtener valores del data source for (int i = 0; i < dbdsMatriz.Size; i++) { //Crear nuevo objeto cae cae = new CAE(); //Obtener valores por linea numeroRegistro = dbdsMatriz.GetValue("DocEntry", i); cae.TipoCFE = CAE.ObtenerTipoCFECFC(dbdsMatriz.GetValue("U_TipoDoc", i)); cae.NombreDocumento = dbdsMatriz.GetValue("U_NombDoc", i); cae.IndicadorConservar = dbdsMatriz.GetValue("U_IndCon", i); //Actualizar la información del registro recorrido manteUdoDocCon.Actualizar(cae, numeroRegistro); } }
private void Salvar(SAPbouiCOM.Form form, DBDataSource dbdts, Matrix mtx) { Global.Company.StartTransaction(); var userTable = Global.Company.UserTables.Item(dbdts.TableName.Remove(0, 1)); mtx.FlushToDataSource(); var peneiraDataSource = _matriz._peneira.Datasource; var nomePeneiraDataSource = _matriz._nomepeneira.Datasource; var ativoDataSource = _matriz._ativo.Datasource; bool ok = true; for (int i = 0; i < dbdts.Size; i++) { var code = dbdts.GetValue("Code", i); if (userTable.GetByKey(code)) { var peneira = dbdts.GetValue(peneiraDataSource, i); var nomePeneira = dbdts.GetValue(nomePeneiraDataSource, i); var ativo = dbdts.GetValue(ativoDataSource, i); userTable.UserFields.Fields.Item(peneiraDataSource).Value = peneira; userTable.UserFields.Fields.Item(nomePeneiraDataSource).Value = nomePeneira; userTable.UserFields.Fields.Item(ativoDataSource).Value = ativo; if (userTable.Update() != 0) { ok = false; break; } } else { throw new Exception($"Erro interno.\nCódigo {code} não encontrado."); } } if (ok) { Global.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); Dialogs.PopupSuccess("Dados salvos com sucesso."); } else { Dialogs.PopupError("Erro ao salvar dados.\nErro: " + Global.Company.GetLastErrorDescription()); } }
private static void ButtonOk(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId) { Form oForm = sbo_application.Forms.Item(formUID); bBubbleEvent = true; if (oItemEvent.EventType == BoEventTypes.et_CLICK) { if (!oItemEvent.BeforeAction) { if (oForm.Mode == BoFormMode.fm_UPDATE_MODE) { DBDataSource dbData = oForm.DataSources.DBDataSources.Add("OBTN"); Matrix oMatrix = (Matrix)oForm.Items.Item(pluginForm.MatrixLote.Uid).Specific; Column oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_DistNumber.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_DistNumber.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_U_FRU_Destino.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_U_FRU_Destino.dbField); dbData.Clear(); oMatrix.FlushToDataSource(); for (int i = 0; i <= dbData.Size - 1; i++) { if (dbData.GetValue(pluginForm.MatrixLote.Colums.Col_DistNumber.dbField, i) != null) { if (dbData.GetValue(pluginForm.MatrixLote.Colums.Col_U_FRU_Destino.dbField, i) != "") { string BatchNum = dbData.GetValue(pluginForm.MatrixLote.Colums.Col_DistNumber.dbField, i); var batch = CommonFunctions.GET(ServiceLayer.BatchNumberDetails, null, $"?$filter=Batch eq '{BatchNum}'", sessionId, out _).DeserializeJsonObject <BatchNumberDetails>(); if (batch.DocEntry != 0) { batch.U_FRU_Destino = dbData.GetValue(pluginForm.MatrixLote.Colums.Col_U_FRU_Destino.dbField, i); CommonFunctions.PATCH(ServiceLayer.BatchNumberDetails, batch, batch.DocEntry.ToString(), sessionId, out _); } } } } BindMatrixData(formUID, ref oItemEvent, sbo_company, ref sbo_application, out bBubbleEvent, sessionId); } oForm.Mode = BoFormMode.fm_OK_MODE; } } }
public bool Almacenar() { SucuDireccion SucDire; ArrayList listaSucuDire = new ArrayList(); //Valida que la matriz contenga información. Si no tiene se ingresa los datos como registros nuevos if (matriz.RowCount > 0) { //Carga el data source con los datos de la matriz matriz.FlushToDataSource(); //Recorre el data source for (int i = 0; i < dataSourceMatriz.Size; i++) { //Crea un nuevo objeto retencion percepcion SucDire = new SucuDireccion(); //Establce las propiedades del objeto SucDire.IdidSucuDire = dataSourceMatriz.GetValue("DocEntry", i); SucDire.Codigo = dataSourceMatriz.GetValue("U_codigo", i).Trim(); SucDire.Calle = dataSourceMatriz.GetValue("U_Calle", i).Trim(); SucDire.Telefono = dataSourceMatriz.GetValue("U_Telefono", i).Trim(); SucDire.Ciudad = dataSourceMatriz.GetValue("U_Ciudad", i).Trim(); //Agrega el objeto a la lista listaSucuDire.Add(SucDire); } //Crea una nueva instancia de adminstracion del udo de SucDire ManteUdoSucuDire manteSucDire = new ManteUdoSucuDire(); //Elimina los registros existentes manteSucDire.Eliminar(listaSucuDire); //Agrega los nuevos registros if (manteSucDire.Almacenar(listaSucuDire)) { CargarMatriz(); AgregarNuevaLinea(); return(true); } } return(false); }
public override void RegrasDeNegocioAoSalvar(SAPbouiCOM.Form form, DBDataSource dbdts) { var numPreContrato = dbdts.GetValue(_numeroDoPreContrato.Datasource, 0); if (string.IsNullOrEmpty(numPreContrato)) { throw new BusinessRuleException("Não foi possível identificar qual o Pré-Contrato referente a este Contrato Final."); } }
public static DateTime GetValueAsDateTime(this DBDataSource dataTable, string field, int rowIndex) { DateTime returnDate = DateTime.MinValue; if (!DateTime.TryParseExact(dataTable.GetValue(field, rowIndex), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out returnDate)) { return(DateTime.MinValue); } return(returnDate); }
/// <summary> /// Almacena las razones de referencia /// </summary> /// <returns></returns> public bool Almacenar() { bool salida = false; RazonReferencia razonReferencia; List <RazonReferencia> listaRazones = new List <RazonReferencia>(); //Valida que la matriz contenga información. Si no tiene se ingresa los datos como registros nuevos if (matriz.RowCount > 0) { //Carga el data source con los datos de la matriz matriz.FlushToDataSource(); //Recorre el data source for (int i = 0; i < dataSourceMatriz.Size; i++) { //Crea un nuevo objeto retencion percepcion razonReferencia = new RazonReferencia(); //Establce las propiedades del objeto razonReferencia.CodigoRazon = dataSourceMatriz.GetValue("U_Codigo", i); razonReferencia.RazonReferenciaNC = dataSourceMatriz.GetValue("U_Razon", i).Trim(); //Agrega el objeto a la lista listaRazones.Add(razonReferencia); } ManteUdoRazonReferencia manteRazRef = new ManteUdoRazonReferencia(); manteRazRef.Eliminar(); //Agrega los nuevos registros if (manteRazRef.Almacenar(listaRazones)) { CargarMatriz(); AgregarNuevaLinea(); salida = true; } } return(salida); }
public override string ProximaChavePrimaria(DBDataSource dbdts) { var numPreContrato = dbdts.GetValue(_numeroDoPreContrato.Datasource, 0); using (var recordset = new RecordSet()) { var rs = recordset.DoQuery( $@"SELECT CONVERT(NVARCHAR, {numPreContrato}) + '.' + CONVERT(NVARCHAR, COUNT(*) + 1) as codigo FROM [{dbdts.TableName}] WHERE {_numeroDoPreContrato.Datasource} = {numPreContrato}"); return(rs.Fields.Item("codigo").Value); } }
public bool Almacenar() { RetencionPercepcion retPer; ArrayList listaRetencionPercepcion = new ArrayList(); //Valida que la matriz contenga información. Si no tiene se ingresa los datos como registros nuevos if (matriz.RowCount > 0) { //Carga el data source con los datos de la matriz matriz.FlushToDataSource(); //Recorre el data source for (int i = 0; i < dataSourceMatriz.Size; i++) { //Crea un nuevo objeto retencion percepcion retPer = new RetencionPercepcion(); //Establce las propiedades del objeto retPer.IdRetencionPercepcion = dataSourceMatriz.GetValue("DocEntry", i); retPer.SujetoPasivo = dataSourceMatriz.GetValue("U_SuPas", i).Trim(); retPer.ContribuyenteRetenido = dataSourceMatriz.GetValue("U_ConRet", i).Trim(); retPer.AgenteResponsable = dataSourceMatriz.GetValue("U_Agente", i).Trim(); retPer.FormularioLineaBeta = dataSourceMatriz.GetValue("U_FormBeta", i).Trim(); retPer.CodigoRetencion = dataSourceMatriz.GetValue("U_CodRet", i).Trim(); //Agrega el objeto a la lista listaRetencionPercepcion.Add(retPer); } //Crea una nueva instancia de adminstracion del udo de retencion/percepcion ManteUdoRetencionPercepcion manteRecPer = new ManteUdoRetencionPercepcion(); //Elimina los registros existentes manteRecPer.Eliminar(listaRetencionPercepcion); //Agrega los nuevos registros if (manteRecPer.Almacenar(listaRetencionPercepcion)) { CargarMatriz(); AgregarNuevaLinea(); return(true); } } return(false); }
/// <summary> /// Update bom masal /// </summary> private void UpdateBomVer_Update(string formUID, ref ItemEvent pVal, ref bool bubbleEvent) { if (bubbleEvent) { if (pVal.BeforeAction == false && pVal.ActionSuccess == true) { SAPbobsCOM.GeneralService oGeneralService; SAPbobsCOM.GeneralData oGeneralData; SAPbobsCOM.CompanyService sCmp; SAPbobsCOM.ProductTrees oBom = (SAPbobsCOM.ProductTrees)oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees); sCmp = oSBOCompany.GetCompanyService(); SAPbobsCOM.GeneralData oGenDataUpdtBom; SAPbobsCOM.GeneralService oGenServiceUpdtBom; Form oForm = oSBOApplication.Forms.Item(formUID); DBDataSource dtSource = null; dtSource = oForm.DataSources.DBDataSources.Item("@SOL_UPBOMVER_H"); string lastDate = dtSource.GetValue("U_SOL_UPDATE", 0); string lastTime = Convert.ToString(int.Parse(dtSource.GetValue("U_SOL_UPTIME", 0).Replace(":", ""))); // Get a handle to the UDO oGeneralService = sCmp.GetGeneralService("BOMVER"); Recordset oRecBomSap = oSBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset); Recordset oRecBomVer = oSBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset); oForm.Freeze(true); try { if (!oSBOCompany.InTransaction) { oSBOCompany.StartTransaction(); } string query = string.Empty; if (oSBOCompany.DbServerType == BoDataServerTypes.dst_HANADB) { query = "CALL SOL_SP_UPDTBOM_GETDIFFBOM('" + lastDate + "', '" + lastTime + "')"; } oRecBomSap.DoQuery(query); if (oRecBomSap.RecordCount > 0) { int progress = 0; oProgressBar = oSBOApplication.StatusBar.CreateProgressBar("Update BOM", oRecBomSap.RecordCount, true); oProgressBar.Text = "Update BOM..."; for (int i = 1; i <= oRecBomSap.RecordCount; i++) { // Get BOM SAP and insert to BOM Version string itemCodeFG = oRecBomSap.Fields.Item("Code").Value; string version = oRecBomSap.Fields.Item("Version").Value; if (oSBOCompany.DbServerType == BoDataServerTypes.dst_HANADB) { query = "CALL SOL_SP_UPDTBOM_GETBOM('" + itemCodeFG + "')"; } oRecBomVer.DoQuery(query); if (oRecBomVer.RecordCount > 0) { oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData); if (!string.IsNullOrEmpty(version)) // jika bom sudah ada di bom version { // non aktivin bom version InactiveBomVer(itemCodeFG); // update aktivin bom version sesuai versinya ActivateBomVer(version); // update versi di bom sap UpdateBOM(itemCodeFG, version, ref bubbleEvent); } else // jika bom belum ada di bom version { // non aktivin bom version InactiveBomVer(itemCodeFG); // add bom version string versionCode = string.Empty; AddBomVer(ref oRecBomVer, ref oGeneralService, ref bubbleEvent, out versionCode); // update versi di bom sap UpdateBOM(itemCodeFG, versionCode, ref bubbleEvent); } } progress += 1; oProgressBar.Value = progress; oRecBomSap.MoveNext(); } // Save ke log update bom version #region Save ke log update bom version oGenServiceUpdtBom = sCmp.GetGeneralService("UPBOMVER"); oGenDataUpdtBom = oGenServiceUpdtBom.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData); oGenDataUpdtBom.SetProperty("Code", GenerateCode()); oGenDataUpdtBom.SetProperty("U_SOL_UPDATE", DateTime.Now.Date.ToShortDateString()); oGenDataUpdtBom.SetProperty("U_SOL_UPTIME", DateTime.Now.ToString("HH:mm:ss", CultureInfo.InvariantCulture)); oGenServiceUpdtBom.Add(oGenDataUpdtBom); #endregion oProgressBar.Stop(); TemplateLoad(ref oForm); oSBOApplication.StatusBar.SetText("Update BOM Success", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); } else { oSBOApplication.MessageBox("Tidak ada data yang dapat di update."); } oSBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } catch (Exception ex) { bubbleEvent = false; oSBOApplication.MessageBox(ex.Message); oSBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } finally { if (oProgressBar != null) { oProgressBar.Stop(); Utils.releaseObject(oProgressBar); } if (oForm != null) { oForm.Freeze(false); } Utils.releaseObject(oRecBomSap); Utils.releaseObject(oRecBomVer); Utils.releaseObject(oGeneralService); } } } }
/// <summary> /// Obtiene los datos de ticket del formuario por linea /// </summary> public List <TicketDetail> GetTicketDetailMatrix(string pStrFolio, SAPbouiCOM.IMatrix mObjMatrix, bool mBolIsUpdate, bool lBolPesaje, DBDataSource pOBjDataSource) { List <TicketDetail> lLstTicketDetail = new List <TicketDetail>(); List <string> lLstDateTime = mObjTicketServices.GetServerDatetime(); try { for (int i = 1; i <= mObjMatrix.RowCount; i++) { float lFloFirstWt = float.Parse(((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("Peso1").Cells.Item(i).Specific).Value); float lFloSecondWT = float.Parse(((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("Peso2").Cells.Item(i).Specific).Value); //Convert.ToDateTime(lLstDateTime[0]) if (((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("ItemCode").Cells.Item(i).Specific).Value != "") { TicketDetail lObjTicketDetail = new TicketDetail(); lObjTicketDetail.Folio = pStrFolio; lObjTicketDetail.Item = ((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("ItemCode").Cells.Item(i).Specific).Value; lObjTicketDetail.Price = float.Parse(((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("Price").Cells.Item(i).Specific).Value); lObjTicketDetail.FirstWT = lFloFirstWt; lObjTicketDetail.SecondWT = lFloSecondWT; lObjTicketDetail.netWeight = float.Parse(((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("PesoN").Cells.Item(i).Specific).Value); lObjTicketDetail.Amount = float.Parse(((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("Importe").Cells.Item(i).Specific).Value); //lObjTicketDetail.WeighingM = // bool lBolWeighingM = ((SAPbouiCOM.CheckBox)mObjMatrix.Columns.Item("Check").Cells.Item(i).Specific).Checked); lObjTicketDetail.Line = i - 1; if (!string.IsNullOrEmpty(pOBjDataSource.GetValue("LineNum", i - 1))) { lObjTicketDetail.BaseLine = Convert.ToInt32(pOBjDataSource.GetValue("LineNum", i - 1)); } if ((mObjMatrix.Columns.Item("Check").Cells.Item(i).Specific as CheckBox).Checked) { lObjTicketDetail.WeighingM = 1; } else { lObjTicketDetail.WeighingM = 0; } if (!lBolPesaje) { lObjTicketDetail.WhsCode = ((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("WhsCode").Cells.Item(i).Specific).Value; lObjTicketDetail.BagsBales = float.Parse(((SAPbouiCOM.EditText)mObjMatrix.Columns.Item("Sacos").Cells.Item(i).Specific).Value); } List <string> lLstTicket = new List <string>(); if (mBolIsUpdate && lObjTicketDetail.Item != "") // Calcula la hora si es una nueva pesada { string lStrcode = mObjTicketServices.getRowCodeDetail(pStrFolio, lObjTicketDetail.Line); List <string> lLstTicketUpdate = mObjTicketServices.GetDateTimeUpdate(lStrcode); if (lLstTicketUpdate.Count > 0) { if (lLstTicketUpdate[1] == "0") { lObjTicketDetail.EntryTime = Convert.ToInt32(lLstDateTime[1].Replace(":", "")); lObjTicketDetail.EntryDate = Convert.ToDateTime(lLstDateTime[0]); } else { lObjTicketDetail.EntryDate = Convert.ToDateTime(lLstTicketUpdate[0]); lObjTicketDetail.EntryTime = Convert.ToInt32(lLstTicketUpdate[1]); } if (lLstTicketUpdate[3] == "0") { lObjTicketDetail.OutputTime = Convert.ToInt32(lLstDateTime[1].Replace(":", "")); lObjTicketDetail.OutputDate = Convert.ToDateTime(lLstDateTime[0]); } else { lObjTicketDetail.EntryDate = Convert.ToDateTime(lLstTicketUpdate[2]); lObjTicketDetail.EntryTime = Convert.ToInt32(lLstTicketUpdate[3]); } } } else { if (lFloFirstWt > 0) { lObjTicketDetail.EntryTime = Convert.ToInt32(lLstDateTime[1].Replace(":", "")); lObjTicketDetail.EntryDate = Convert.ToDateTime(lLstDateTime[0]); } if (lFloSecondWT > 0) { lObjTicketDetail.OutputTime = Convert.ToInt32(lLstDateTime[1].Replace(":", "")); lObjTicketDetail.OutputDate = Convert.ToDateTime(lLstDateTime[0]); } } lLstTicketDetail.Add(lObjTicketDetail); } } } catch (Exception ex) { LogService.WriteError("[GetTicketDetailMatrix]: " + ex.Message); LogService.WriteError(ex); } return(lLstTicketDetail); }
/// <summary> /// Gets the string. /// </summary> /// <param name="source">The source.</param> /// <param name="columnId">The column identifier.</param> /// <param name="rowIndex">Index of the row.</param> /// <returns></returns> public static string GetString(this DBDataSource source, string columnId, int rowIndex) { var sourceValue = source.GetValue(columnId, rowIndex); return(sourceValue?.Trim()); }
public static double GetValueAsDouble(this DBDataSource dataTable, string fieldName, int rowIndex) { return(Convert.ToDouble(dataTable.GetValue(fieldName, rowIndex), CultureInfo.InvariantCulture)); }
public static string Val(this DBDataSource dataTable, string field) { return(dataTable.GetValue(field, dataTable.Offset)); }