Esempio n. 1
0
        public static void UpdateWithValidation(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            if (IsValid(row))
            {
                SqlConnection cnx = dbhelper.Connection.GetConnection();;
                cnx.Open();

                SqlTransaction trx = cnx.BeginTransaction(IsolationLevel.Serializable);

                try
                {
                    string IdTDCompTesoreria = string.Empty;
                    Update(row, trx);
                    IdTDCompTesoreria = Convert.ToString(row.IdTDCompTesoreria);

                    // se actualizan la variables terminadas en ',', apra que se agregue el ID recientemente insertado
                    if (_state.ToUpper().Equals("NEW"))
                    {
                        foreach (sy_VariablesDataset.sy_VariablesRow rowV in _dataVariables.sy_Variables.Rows)
                        {
                            string str = Convert.ToString(rowV["ValorDefault"]);
                            int    x   = str.LastIndexOf(',');
                            if (str.Length != 0 && (x + 1 == str.Length))
                            {
                                rowV["ValorDefault"] = str + Convert.ToString(row["IdTDCompTesoreria"]);
                            }
                        }
                    }

                    if (_dataCompEntidades != null)
                    {
                        foreach (tfi_TDCompTesoreria_EntidadesDataset.tfi_TDCompTesoreria_EntidadesRow rowE in _dataCompEntidades.tfi_TDCompTesoreria_Entidades.Rows)
                        {
                            //actualizo el id del comp tesoreria
                            rowE["TDCompTesoreria"] = row["idTDCompTesoreria"];
                        }
                    }
                    if (_dataTDCompTesoreria_CondicionesDeVentas != null)
                    {
                        foreach (tfi_TDCompTesoreria_CondicionesDeVentaDataset.tfi_TDCompTesoreria_CondicionesDeVentaRow row_TDCT_CV in _dataTDCompTesoreria_CondicionesDeVentas.tfi_TDCompTesoreria_CondicionesDeVenta.Rows)
                        {
                            row_TDCT_CV.idTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }

                    if (_dataTDCompTesoreria_Monedas_Recargos != null)
                    {
                        foreach (tfi_TDCompTesoreriasMonedasRecargosDataset.tfi_TDCompTesoreriasMonedasRecargosRow row_TDCT_M_R in _dataTDCompTesoreria_Monedas_Recargos.tfi_TDCompTesoreriasMonedasRecargos.Rows)
                        {
                            row_TDCT_M_R.IdTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }
                    if (_dataCuentas_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        foreach (tsa_CuentasCondicionesDeVenta_TDCompTesoreriaDataset.tsa_CuentasCondicionesDeVenta_TDCompTesoreriaRow row_C_CV_TDCT in _dataCuentas_CondicionesDeVentas_TDCompTesoreria.tsa_CuentasCondicionesDeVenta_TDCompTesoreria.Rows)
                        {
                            row_C_CV_TDCT.idTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }

                    if (_dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        foreach (Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreriaDataset.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreriaRow row_TC_CV_TDCT in _dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreria.Rows)
                        {
                            row_TC_CV_TDCT.IdTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }

                    if (_dataConfiguracionFDP != null)
                    {
                        if (_dataConfiguracionFDP.tui_ConfiguracionFormasDePago.Rows.Count > 0)
                        {
                            _dataConfiguracionFDP.tui_ConfiguracionFormasDePago.Rows[0]["IdTDCompTesoreria"] = Convert.ToString(row["IdTDCompTesoreria"]);
                        }
                    }
                    if (_dataAgrupamientoTDCompTesoreria != null)
                    {
                        if (_dataAgrupamientoTDCompTesoreria.tfi_AgrupTDCompTesoreria.Rows.Count > 0)
                        {
                            _dataAgrupamientoTDCompTesoreria.tfi_AgrupTDCompTesoreria.Rows[0]["IdTDCompTesoreria"] = Convert.ToString(row["IdTDCompTesoreria"]);
                        }
                    }
                    mz.erp.dataaccess.sy_Variables.Update(_dataVariables.sy_Variables, trx);
                    mz.erp.dataaccess.sy_VariablesPerfiles.Update(_dataVariablesPerfiles.sy_VariablesPerfiles, trx);
                    //mz.erp.dataaccess.sy_Variables.Update(_dataVariablesABorrar.sy_Variables, trx);
                    //mz.erp.dataaccess.sy_VariablesPerfiles.Update(_dataVariablesPerfilesABorrar.sy_VariablesPerfiles , trx);
                    mz.erp.dataaccess.tfi_TDCompTesoreria_Entidades.Update(_dataCompEntidades.tfi_TDCompTesoreria_Entidades, trx);
                    mz.erp.dataaccess.tui_ConfiguracionFormasDePago.Update(_dataConfiguracionFDP.tui_ConfiguracionFormasDePago, trx);
                    if (_dataAgrupamientoTDCompTesoreria != null)
                    {
                        if (_state.Equals("NEW"))
                        {
                            mz.erp.dataaccess.tfi_AgrupTDCompTesoreria.Update(_dataAgrupamientoTDCompTesoreria.tfi_AgrupTDCompTesoreria, trx);
                        }
                    }
                    if (_dataTDCompTesoreria_CondicionesDeVentas != null)
                    {
                        mz.erp.dataaccess.tfi_TDCompTesoreria_CondicionesDeVenta.Update(_dataTDCompTesoreria_CondicionesDeVentas.tfi_TDCompTesoreria_CondicionesDeVenta, trx);
                    }
                    mz.erp.dataaccess.tfi_TDCompTesoreriasMonedasRecargos.Update(_dataTDCompTesoreria_Monedas_Recargos.tfi_TDCompTesoreriasMonedasRecargos, trx);
                    if (_dataCuentas_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        mz.erp.dataaccess.tsa_CuentasCondicionesDeVenta_TDCompTesoreria.Update(_dataCuentas_CondicionesDeVentas_TDCompTesoreria.tsa_CuentasCondicionesDeVenta_TDCompTesoreria, trx);
                    }
                    if (_dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        mz.erp.dataaccess.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreria.Update(_dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreria, trx);
                    }
                    Variables.Reset();                     //reinicia las variables;
                    MAPStaticInfo.Reset();
                    trx.Commit();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message.ToString());
                    trx.Rollback();
                }
                finally
                {
                    cnx.Close();
                }
            }
        }