コード例 #1
0
        /// <summary>
        /// Удаляет запись из базы данных
        /// </summary>
        /// <param name="BUDGETPROJECT_GUID">УИ проекта</param>
        /// <param name="objProfile">профайл</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - запись удалена; false - ошибка</returns>
        public static System.Boolean RemoveObjectFromDataBase(System.Guid BUDGETPROJECT_GUID,
                                                              UniXP.Common.CProfile objProfile, ref System.String strErr)
        {
            System.Boolean bRet = false;

            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;

            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    strErr += ("Не удалось получить соединение с базой данных.");
                    return(bRet);
                }
                DBTransaction   = DBConnection.BeginTransaction();
                cmd             = new System.Data.SqlClient.SqlCommand();
                cmd.Connection  = DBConnection;
                cmd.Transaction = DBTransaction;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_DeleteBudgetProject]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BUDGETPROJECT_GUID", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000));
                cmd.Parameters["@ERROR_MES"].Direction      = System.Data.ParameterDirection.Output;
                cmd.Parameters["@BUDGETPROJECT_GUID"].Value = BUDGETPROJECT_GUID;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes == 0)
                {
                    // подтверждаем транзакцию
                    DBTransaction.Commit();
                }
                else
                {
                    DBTransaction.Rollback();
                    strErr += ((cmd.Parameters["@ERROR_MES"].Value == System.DBNull.Value) ? "" : (System.String)cmd.Parameters["@ERROR_MES"].Value);
                }

                cmd.Dispose();
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                DBTransaction.Rollback();

                strErr += ("Не удалось удалить объект 'проект'. Текст ошибки: " + f.Message);
            }
            finally
            {
                DBConnection.Close();
            }
            return(bRet);
        }
コード例 #2
0
 public bool Confirmar(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario)
 {
     foreach (HojaRutaInternoGuia guiaHojaRutaInterno in this.guiasHojaRutaInterno)
     {
         GuiaEstadoHistorico oGuiaEstado = new GuiaEstadoHistorico();
         guiaHojaRutaInterno.HojaRutaInternoID = this.hojaRutaInternoID;
         if (guiaHojaRutaInterno.Guardar(transaccion))
         {
             oGuiaEstado.GuiaID           = guiaHojaRutaInterno.GuiaID;
             oGuiaEstado.EstadoGuiaID     = (int)SisPack.ValorEstadoSubAgencias.AsignadaHojaRutaInterna;
             oGuiaEstado.TipoEstadoGuiaID = SisPack.TipoEstadoGuia.EstadoSubAgencias;
             oGuiaEstado.UsuarioID        = usuario.UsuarioID;
             oGuiaEstado.FechaHis         = DateTime.Today;
             oGuiaEstado.AgenciaID        = agenciaUsuaria;
             oGuiaEstado.Observaciones    = "";
             oGuiaEstado.Guardar(transaccion);
         }
         else
         {
             transaccion.Rollback();
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
        static bool InsertBook(string id, string title, string pubyear)
        {
            bool   result = true;
            string sql    = $"INSERT INTO Books(title,publishYear) VALUES('{title}',{pubyear})";
            string cnstr  = "server=student\\sqlexpress;database=library;integrated security=true";

            using (System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(cnstr))
            {
                cn.Open();
                System.Data.SqlClient.SqlTransaction tx = cn.BeginTransaction();
                System.Data.SqlClient.SqlCommand     cm = new System.Data.SqlClient.SqlCommand(sql, cn, tx);
                try
                {
                    cm.ExecuteNonQuery();
                    tx.Commit();
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    tx.Rollback();
                    result = false;
                }
                finally
                {
                    cn.Close();
                }
            }//close using block
            return(result);
        }
コード例 #4
0
ファイル: NhapKho.cs プロジェクト: thachgiasoft/vppproj
 private bool DeleteTakeIn(int p_IdTakeIn)
 {
     System.Data.SqlClient.SqlConnection _sqlConnection = new System.Data.SqlClient.SqlConnection(_ConfigItem.StrConnection);;
     if (_sqlConnection.State != ConnectionState.Open)
     {
         _sqlConnection.Open();
     }
     System.Data.SqlClient.SqlTransaction _sqlTransaction = _sqlConnection.BeginTransaction();
     try
     {
         _providerSQL = new COREBASE.COMMAND.SQL.AccessSQL();
         string[] arrName  = new string[] { "@Id", "@Mod_By" };
         object[] arrValue = new object[] { p_IdTakeIn, _ConfigItem.Login_UserName };
         _providerSQL.ExecuteNonQuery(_sqlConnection, _sqlTransaction, "USP_DEL_TAKE_IN", arrName, arrValue);
         _sqlTransaction.Commit();
         return(true);
     }
     catch (Exception ex)
     {
         _sqlTransaction.Rollback();
         AppDebug(ex);
         if (_sqlConnection.State != ConnectionState.Closed)
         {
             _sqlConnection.Close();
         }
         return(false);
     }
 }
コード例 #5
0
ファイル: NhapKho.cs プロジェクト: thachgiasoft/vppproj
        private bool InsertData(DataTable tbDetail, int _id_WareHouse, int _TotalAMT, int _iId_Supplier_Pk, DateTime _iTake_In_Date, int _User_Pk, string _BillNumber, string _Remark, DateTime _billdate)
        {
            System.Data.SqlClient.SqlConnection _sqlConnection = new System.Data.SqlClient.SqlConnection(_ConfigItem.StrConnection);
            if (_sqlConnection.State != ConnectionState.Open)
            {
                _sqlConnection.Open();
            }
            System.Data.SqlClient.SqlTransaction _sqlTransaction = _sqlConnection.BeginTransaction();
            try
            {
                int _iNumberItem = tbDetail.Rows.Count;

                string[] arrName  = new string[] { "@Supplier_Pk", "@Take_In_Date", "@Number_Item", "@TotalAMT", "@Crt_By", "@WareHouse_Pk", "@Remark", "@BillNumber", "@BillDate", "@User_Pk" };
                object[] arrValue = new object[] { _iId_Supplier_Pk, _iTake_In_Date, _iNumberItem, _TotalAMT, _ConfigItem.Login_UserName, _id_WareHouse, _Remark, _BillNumber, _billdate, _User_Pk };
                _providerSQL = new COREBASE.COMMAND.SQL.AccessSQL();
                int _idMaster = _providerSQL.ExecuteInsert(_sqlConnection, _sqlTransaction, "USP_INS_TAKE_IN", arrName, arrValue);
                for (int i = 0; i < _iNumberItem; i++)
                {
                    arrName = new string[] {
                        "@Take_In_Pk",
                        "@Crt_By",
                        "@Remark",
                        "@Number_Bill",
                        "@Number_Real",
                        "@Price",
                        "@Vat",
                        "@Item_Pk",
                        "@UnitStyle_Pk"
                    };
                    arrValue = new object[] {
                        _idMaster,
                        _ConfigItem.Login_UserName,
                        string.Empty,
                        tbDetail.Rows[i]["Number_Bill"],
                        tbDetail.Rows[i]["Number_Real"],
                        tbDetail.Rows[i]["Price"],
                        tbDetail.Rows[i]["Vat"],
                        tbDetail.Rows[i]["Item_Pk"],
                        tbDetail.Rows[i]["UnitStyle_Pk"]
                    };
                    _providerSQL.ExecuteNonQuery(_sqlConnection, _sqlTransaction, "USP_INS_TAKE_IN_DETAIL", arrName, arrValue);
                }
                _sqlTransaction.Commit();
                _providerSQL.Disconnect(_sqlConnection);
                return(true);
            }
            catch (Exception ex)
            {
                _sqlTransaction.Rollback();
                AppDebug(ex);
                if (_providerSQL != null)
                {
                    if (_sqlConnection != null)
                    {
                        _providerSQL.Disconnect(_sqlConnection);
                    }
                }
                return(false);
            }
        }
コード例 #6
0
ファイル: NhapKho.cs プロジェクト: thachgiasoft/vppproj
 private bool DeleteItem(int[] p_selectRow, DataTable p_datasource)
 {
     System.Data.SqlClient.SqlConnection _sqlConnection = new System.Data.SqlClient.SqlConnection(_ConfigItem.StrConnection);;
     if (_sqlConnection.State != ConnectionState.Open)
     {
         _sqlConnection.Open();
     }
     System.Data.SqlClient.SqlTransaction _sqlTransaction = _sqlConnection.BeginTransaction();
     try
     {
         _providerSQL = new COREBASE.COMMAND.SQL.AccessSQL();
         string[] arrName = new string[] { "@Id", "@Mod_By", "@Mod_Dt" };
         for (int i = 0; i < p_selectRow.Length; i++)
         {
             object[] arrValue = new object[] { p_datasource.Rows[i]["Id"], _ConfigItem.Login_UserName, DateTime.Now };
             _providerSQL.ExecuteNonQuery(_sqlConnection, _sqlTransaction, "USP_DEL_TAKE_IN_DETAIL", arrName, arrValue);
         }
         _sqlTransaction.Commit();
         return(true);
     }
     catch (Exception ex)
     {
         _sqlTransaction.Rollback();
         AppDebug(ex);
         if (_sqlConnection.State != ConnectionState.Closed)
         {
             _sqlConnection.Close();
         }
         return(false);
     }
 }
コード例 #7
0
 private void btnUpdateModule_Click(object sender, EventArgs e)
 {
     System.Data.SqlClient.SqlTransaction trans = BWS.ERP.BaseControl.ConnectSetting.SysSqlConnection.BeginTransaction();
     try
     {
         foreach (DataRow item in dsModule.Tables[0].Rows)
         {
             if (item.RowState == DataRowState.Added)
             {
                 item["ID"] = dalMenuNode.Add(item, trans);
             }
             if (item.RowState == DataRowState.Modified)
             {
                 dalMenuNode.Update(item, trans);
             }
             if (item.RowState == DataRowState.Deleted)
             {
                 dalMenuNode.Delete(Convert.ToInt32(item["ID", DataRowVersion.Original]), trans);
             }
         }
         trans.Commit();
         //刷新菜单
         initModule();
         initModuleBingding();
         BWS.ERP.BaseControl.Public.SystemInfo("升级成功!");
     }
     catch (Exception ex)
     {
         trans.Rollback();
         BWS.ERP.BaseControl.Public.SystemInfo("升级失败!" + ex.Message, true);
     }
 }
コード例 #8
0
 public bool ArchivarGuiasDePlanilla(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario, string nroCaja)
 {
     foreach (PlanillaRemitoClienteGuias guiaPlanilla in this.guiasPlanilla)
     {
         GuiaEstadoHistorico oGuiaEstado = new GuiaEstadoHistorico();
         oGuiaEstado.GuiaID           = guiaPlanilla.GuiaID;
         oGuiaEstado.EstadoGuiaID     = (int)SisPack.ValorEstadoEstatico.EnArchivo;
         oGuiaEstado.TipoEstadoGuiaID = SisPack.TipoEstadoGuia.EstadoEstatico;
         oGuiaEstado.UsuarioID        = usuario.UsuarioID;
         oGuiaEstado.FechaHis         = DateTime.Today;
         oGuiaEstado.AgenciaID        = agenciaUsuaria;
         //oGuiaEstado.Observaciones = obs;
         oGuiaEstado.Observaciones = "";
         if (!oGuiaEstado.Guardar(transaccion))
         {
             transaccion.Rollback();
             return(false);
         }
         GuiaEstadoHistoricoDatos oGuiaDatos = new GuiaEstadoHistoricoDatos();
         oGuiaDatos.GuiaID            = guiaPlanilla.GuiaID;
         oGuiaDatos.GuiaEstadoHisID   = oGuiaEstado.GuiaEstadoHisID;
         oGuiaDatos.EstadoGuiaDatosID = (int)SisPack.DatosEstadoEstaticoEnCajaDeArchivo.NroCajaArchivo;
         oGuiaDatos.Valor             = nroCaja;
         oGuiaDatos.Guardar(transaccion);
     }
     return(true);
 }
コード例 #9
0
        public string efetuaQuitacao(string pCodigoParcela, double pValorQuitado, string pNumeroAutorizacao)
        {
            System.Data.SqlClient.SqlTransaction iTransacao = bancoDados.Conexoes.conexao.BeginTransaction();

            try
            {
                if (getExisteAutorizacao(pNumeroAutorizacao, iTransacao))
                {
                    throw new Exception("autorizacao ja cadastrada");
                }

                if (setQuitacaoCartao(pCodigoParcela, pValorQuitado, pNumeroAutorizacao, iTransacao))
                {
                    throw new Exception("O vencimento nao pode ser anterior a data atual");
                }

                iTransacao.Commit();

                return("OK");
            }
            catch (Exception ex)
            {
                if (iTransacao.Connection != null)
                {
                    iTransacao.Rollback();
                }

                throw new Exception("class:" + this.GetType().Name + "\r\n Method:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\r\n" + ex.Message);
            }
            finally { bancoDados.Conexoes.close(); }
        }
コード例 #10
0
        }//

        public static void trxCloser(
            System.Data.SqlClient.SqlTransaction trx,
            bool mustCommit // the ultimate decision.
            )
        {
            if (mustCommit)// success
            {
                trx.Commit();
            }
            else// failure
            {
                if (null != trx)
                {
                    trx.Rollback();
                }// else means the the trxOpener was unable to connect.
            }
            if (null != trx)
            {
                if (null != trx.Connection)
                {
                    if (System.Data.ConnectionState.Open == trx.Connection.State)
                    {
                        trx.Connection.Close();
                    } // else aready closed.
                }     //else Commit or Rollback succeeded and let trx.Connection==null.
            }         // else means the the trxOpener was unable to connect.
            //--END--close transazione------
            trx = null;// anyway garbage collect.
            // ready
        } // end trxCloser
コード例 #11
0
 public bool Guardar(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario)
 {
     foreach (PlanillaRemitoClienteGuias guiaPlanilla in this.guiasPlanilla)
     {
         GuiaEstadoHistorico oGuiaEstado = new GuiaEstadoHistorico();
         guiaPlanilla.PlanillaRemitoClienteID = this.PlanillaRemitoClienteID;
         if (guiaPlanilla.Guardar(transaccion))
         {
             oGuiaEstado.GuiaID           = guiaPlanilla.GuiaID;
             oGuiaEstado.EstadoGuiaID     = (int)SisPack.ValorEstadoRendicionAdministracion.EnPlanillaRendicionCliente;
             oGuiaEstado.TipoEstadoGuiaID = SisPack.TipoEstadoGuia.EstadoRendicionAdministracion;
             oGuiaEstado.UsuarioID        = usuario.UsuarioID;
             oGuiaEstado.FechaHis         = DateTime.Today;
             oGuiaEstado.AgenciaID        = agenciaUsuaria;
             //oGuiaEstado.Observaciones = obs;
             oGuiaEstado.Observaciones = "";
             oGuiaEstado.Guardar(transaccion);
         }
         else
         {
             transaccion.Rollback();
             return(false);
         }
     }
     return(true);
 }
コード例 #12
0
        //
        //System.Web.Security.RoleProvider methods.
        //
        //RoleProvider.AddUsersToRoles
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            foreach (var rolename in roleNames)
            {
                if (!RoleExists(rolename))
                {
                    throw new ProviderException("Role name not found.");
                }
            }

            foreach (var username in usernames)
            {
                if (username.Contains(","))
                {
                    throw new ArgumentException("Usernames cannot contain commas.");
                }

                foreach (var rolename in roleNames)
                {
                    if (IsUserInRole(username, rolename))
                    {
                        throw new ProviderException("User is already in role.");
                    }
                }
            }

            System.Data.SqlClient.SqlTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();
                alphaCmd.Transaction = tran;

                foreach (var username in usernames)
                {
                    foreach (var rolename in roleNames)
                    {
                        alphaCmd.CommandText = " INSERT INTO UsersInRoles " +
                                               " (Username, Rolename, ApplicationName) " +
                                               " Values('" + username + "', '" + rolename + "', '" + ApplicationName + "')";

                        alphaCmd.ExecuteNonQuery();
                    }
                }
                tran.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    tran.Rollback();
                }
                catch (Exception ex2) { }
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #13
0
        public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames)
        {
            foreach (string rolename in rolenames)
            {
                if (!RoleExists(rolename))
                {
                    throw new ProviderException("Role name not found.");
                }
            }

            foreach (string username in usernames)
            {
                foreach (string rolename in rolenames)
                {
                    if (!IsUserInRole(username, rolename))
                    {
                        throw new ProviderException("User is not in role.");
                    }
                }
            }

            System.Data.SqlClient.SqlTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();
                alphaCmd.Transaction = tran;

                foreach (string username in usernames)
                {
                    foreach (string rolename in rolenames)
                    {
                        alphaCmd.CommandText = " DELETE FROM UsersInRoles " +
                                               " WHERE Username = '******' " +
                                               "   And Rolename = '" + rolename + "' " +
                                               "   And ApplicationName = '" + ApplicationName + "' ";

                        alphaCmd.ExecuteNonQuery();
                    }
                }

                tran.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    tran.Rollback();
                }
                catch (Exception ex2) { }

                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #14
0
 public void RollBackTran()
 {
     if (tran != null)
     {
         tran.Rollback();
         tran = null;
     }
 }
コード例 #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlTransaction trans = BWS.ERP.BaseControl.ConnectSetting.SysSqlConnection.BeginTransaction();
            try
            {
                //重建菜单顺序
                foreach (DevExpress.XtraTreeList.Nodes.TreeListNode node in tvMenu.Nodes)
                {
                    AutoSetMenuSort(node);
                }
                //下次保存前将顺序号清空为0
                iSort = 0;
                foreach (DataRow item in dsMenu.Tables[0].Rows)
                {
                    if (item.RowState == DataRowState.Added)
                    {
                        item["ID"] = dalMenu.Add(item, trans);
                    }
                    if (item.RowState == DataRowState.Modified)
                    {
                        dalMenu.Update(item, trans);
                    }
                    if (item.RowState == DataRowState.Deleted)
                    {
                        dalMenu.Delete(Convert.ToInt32(item["ID", DataRowVersion.Original]), trans);
                    }
                }

                //保存菜单参数表
                foreach (DataRow item in dsMenuPara.Tables[0].Rows)
                {
                    if (item.RowState == DataRowState.Added)
                    {
                        item["ID"] = dalMenuParam.Add(item, trans);
                    }
                    if (item.RowState == DataRowState.Modified)
                    {
                        dalMenuParam.Update(item, trans);
                    }
                    if (item.RowState == DataRowState.Deleted)
                    {
                        dalMenuParam.Delete(Convert.ToInt32(item["ID", DataRowVersion.Original]), trans);
                    }
                }

                trans.Commit();
                //刷新菜单
                initMenu();
                tvMenu.OptionsBehavior.Editable = false;
                BWS.ERP.BaseControl.Public.SystemInfo("保存成功!");
            }
            catch (Exception ex)
            {
                trans.Rollback();
                BWS.ERP.BaseControl.Public.SystemInfo("保存失败!" + ex.Message, true);
            }
        }
コード例 #16
0
        /// <summary>
        /// Inclui um novo cliente
        /// </summary>
        /// <param name="cliente">Objeto de cliente</param>
        internal long Incluir(DML.Cliente cliente)
        {
            long ret = 0;

            using (System.Data.SqlClient.SqlConnection conexao = Connection())
            {
                conexao.Open();

                System.Data.SqlClient.SqlCommand     comando   = conexao.CreateCommand();
                System.Data.SqlClient.SqlTransaction transacao = conexao.BeginTransaction("IncluirCliente");

                comando.Connection  = conexao;
                comando.Transaction = transacao;

                try
                {
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.CommandText = "[FI_SP_IncClienteV2]";

                    comando.Parameters.AddWithValue("@Nome", cliente.Nome);
                    comando.Parameters.AddWithValue("@Sobrenome", cliente.Sobrenome);
                    comando.Parameters.AddWithValue("@CPF", TextoHelper.RemoveNaoNumericos(cliente.CPF));
                    comando.Parameters.AddWithValue("@Nacionalidade", cliente.Nacionalidade);
                    comando.Parameters.AddWithValue("@CEP", cliente.CEP);
                    comando.Parameters.AddWithValue("@Estado", cliente.Estado);
                    comando.Parameters.AddWithValue("@Cidade", cliente.Cidade);
                    comando.Parameters.AddWithValue("@Logradouro", cliente.Logradouro);
                    comando.Parameters.AddWithValue("@Email", cliente.Email ?? string.Empty);
                    comando.Parameters.AddWithValue("@Telefone", cliente.Telefone ?? string.Empty);

                    var idCliente = comando.ExecuteScalar();

                    cliente.Id = Convert.ToInt64(idCliente);

                    foreach (Beneficiario beneficiario in cliente.Beneficiarios)
                    {
                        comando.Parameters.Clear();
                        comando.CommandText = "[FI_SP_IncBeneficiario]";
                        comando.Parameters.AddWithValue("@CPF", TextoHelper.RemoveNaoNumericos(beneficiario.CPF));
                        comando.Parameters.AddWithValue("@NOME", beneficiario.Nome);
                        comando.Parameters.AddWithValue("@IDCLIENTE", cliente.Id);

                        comando.ExecuteNonQuery();
                    }

                    ret = cliente.Id;

                    transacao.Commit();
                }
                catch (Exception ex)
                {
                    transacao.Rollback();
                }
            }

            return(ret);
        }
        /// <summary>
        /// Rolls back the transaction and disposes the underlying connection.
        /// </summary>
        public void Rollback()
        {
            if (m_Disposed)
            {
                throw new ObjectDisposedException("Transaction is disposed");
            }

            m_Transaction.Rollback();
            Dispose(true);
        }
コード例 #18
0
        public bool Guardar(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario)
        {
            int rendicionID = 0;

            foreach (GuiaRendicionDetalle guiaRendida in this.guiasRendidas)
            {
                rendicionID = guiaRendida.RendicionAgenciaID;
                GuiaEstadoHistorico      oGuiaEstado = new GuiaEstadoHistorico();
                GuiaEstadoHistoricoDatos oGuiaDatos  = new GuiaEstadoHistoricoDatos();
                guiaRendida.GuiaID = this.GuiaID;       //ID de la guía de rendición
                if (guiaRendida.Guardar(transaccion))
                {
                    //try
                    //{

                    if (guiaRendida.GuiaRendidaID != 0)
                    {
                        oGuiaEstado.GuiaID           = guiaRendida.GuiaRendidaID;
                        oGuiaEstado.EstadoGuiaID     = (int)SisPack.ValorEstadoRendicionAdministracion.EnGuiaRendicion;
                        oGuiaEstado.TipoEstadoGuiaID = SisPack.TipoEstadoGuia.EstadoRendicionAdministracion;
                        oGuiaEstado.UsuarioID        = usuario.UsuarioID;
                        oGuiaEstado.FechaHis         = DateTime.Today;
                        oGuiaEstado.AgenciaID        = agenciaUsuaria;
                        //oGuiaEstado.Observaciones = obs;
                        oGuiaEstado.Observaciones = "";
                        oGuiaEstado.Guardar(transaccion);

                        //Guarda informacion en la Tabla GuiaEstadoHistoricoDatos acerca de la guia de rendicion
                        oGuiaDatos.GuiaID            = guiaRendida.GuiaRendidaID;
                        oGuiaDatos.GuiaEstadoHisID   = oGuiaEstado.GuiaEstadoHisID;
                        oGuiaDatos.EstadoGuiaDatosID = (int)SisPack.DatosEstadoRendicionAdministracionEnGuiaRendicion.GuiaID;
                        oGuiaDatos.Valor             = this.GuiaID.ToString();
                        oGuiaDatos.Guardar(transaccion);
                    }
                    //}
                    //catch (Exception ex)
                    //{

                    //}
                }
                else
                {
                    transaccion.Rollback();
                    return(false);
                }
            }
            //Diego 16/07/2013
            //Agregado para relacionar las rendiciones anteriores que no tienen guia de rendicion con la nueva rendicion que si tiene guia de rendicion
            if (GuiaID != 0)
            {
                AsociarRendiciones(transaccion, GuiaID, rendicionID);
            }
            return(true);
        }
コード例 #19
0
 public bool Devolver(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario)
 {
     foreach (GuiaUnidadLogisticaDetalle guiaUnidadLogistica in this.guiasUnidadesLogisticas)
     {
         if (!guiaUnidadLogistica.Devolver(transaccion))
         {
             transaccion.Rollback();
             return(false);
         }
     }
     return(true);
 }
コード例 #20
0
 public void ImporteRedespacho(System.Data.SqlClient.SqlTransaction transaccion, double kilajeSaca)
 {
     try
     {
         Config.Conexion.EjecutarSinResultados(transaccion, "CalcularImporteRedespacho", ConsolidadoID, GuiaID, kilajeSaca);
     }
     catch (Exception ex)
     {
         transaccion.Rollback();
         throw ex;
     }
 }
コード例 #21
0
        //RoleProvider.DeleteRole
        public override bool DeleteRole(string rolename, bool throwOnPopulatedRole)
        {
            if (!RoleExists(rolename))
            {
                throw new ProviderException("Role does not exist.");
            }

            //If throwOnPopulatedRole AndAlso GetUsersInRole(rolename).Length > 0 Then
            //  Throw New ProviderException("Cannot delete a populated role.")
            //End If

            alphaCmd.CommandText = " DELETE FROM Roles " +
                                   " WHERE Rolename = '" + rolename + "' and ApplicationName = '" + ApplicationName + "' ";

            var cmd2 = new System.Data.SqlClient.SqlCommand();

            cmd2.Connection  = conn;
            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = " DELETE FROM UsersInRoles " +
                               " WHERE Rolename = '" + rolename + "' and ApplicationName = '" + ApplicationName + "' ";

            System.Data.SqlClient.SqlTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();
                alphaCmd.Transaction = tran;
                cmd2.Transaction     = tran;

                cmd2.ExecuteNonQuery();
                alphaCmd.ExecuteNonQuery();

                tran.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    tran.Rollback();
                }
                catch (Exception ex2) { }

                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(true);
        }
コード例 #22
0
 public bool Guardar(System.Data.SqlClient.SqlTransaction transaccion)
 {
     foreach (ConceptoLiquidacionDetalle conceptoLiqDe in this.conceptosLiqDetalle)
     {
         conceptoLiqDe.ConceptoLiquidacionID = this.ConceptoLiquidacionID;
         if (!conceptoLiqDe.Guardar(transaccion))
         {
             transaccion.Rollback();
             return(false);
         }
     }
     //transaccion.Commit();
     return(true);
 }
コード例 #23
0
        public string setAlteraVencimento(string pCodigoParcela, double pValor, DateTime pVencimento)
        {
            System.Data.SqlClient.SqlTransaction iTransacao = bancoDados.Conexoes.conexao.BeginTransaction();

            try
            {
                if (pVencimento < DateTime.Today)
                {
                    throw new Exception("O vencimento nao pode ser anterior a data atual");
                }

                if (pVencimento > DateTime.Today.AddDays(15))
                {
                    throw new Exception("O vencimento nao pode ser maior que 15 dias ");
                }

                bancoDados.Comandos.limpaParametros();
                bancoDados.Comandos.textoComando = "Principal.Cobranca.Proc_AlteraParcela";
                bancoDados.Comandos.tipoComando  = System.Data.CommandType.StoredProcedure;
                bancoDados.retornaDados          = true;

                bancoDados.Comandos.adicionaParametro("@CdParcela", System.Data.SqlDbType.BigInt, 4, pCodigoParcela);
                bancoDados.Comandos.adicionaParametro("@VlParcela", System.Data.SqlDbType.Money, 4, pValor);
                bancoDados.Comandos.adicionaParametro("@DtVencimento", System.Data.SqlDbType.DateTime, 8, pVencimento);
                bancoDados.Comandos.adicionaParametro("@CdCobrador ", System.Data.SqlDbType.VarChar, 6, codigoCobradora);


                bancoDados.Comandos.comando.Transaction = iTransacao;

                System.Data.DataTable iTabela = bancoDados.execute().Tables[0];

                if (Convert.ToBoolean(iTabela.Rows[0]["isEfetuada"]))
                {
                    iTransacao.Commit();
                    return(CarSystem.Utilidades.Rede.HTML.tableToJson(iTabela));
                }

                throw new Exception(iTabela.Rows[0]["isEfetuada"].ToString());
            }
            catch (Exception ex)
            {
                if (iTransacao.Connection != null)
                {
                    iTransacao.Rollback();
                }

                throw new Exception("class:" + this.GetType().Name + "\r\n Method:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\r\n" + ex.Message);
            }
            finally { bancoDados.Conexoes.close(); }
        }
コード例 #24
0
        public ActionResult NoInTrun()
        {
            string dateStr = Request["dateStr"];

            DBModel.ApartmentCashEntities ef = new DBModel.ApartmentCashEntities();

            System.Data.Entity.Database db = ef.Database;

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(db.Connection.ConnectionString))
            {
                conn.Open();
                System.Data.SqlClient.SqlTransaction trans = conn.BeginTransaction();

                try
                {
                    string sql2 = string.Format(@"
                        update  a
                        set a.UserID=b.UserID
                        from DateWash a
                        inner join DateWash b on a.DateWashID=b.DateWashID+1
                        where a.DateStr>'{0}'", dateStr);

                    System.Data.SqlClient.SqlCommand cmd2 = new System.Data.SqlClient.SqlCommand(sql2, conn, trans);
                    cmd2.ExecuteNonQuery();

                    string sql = string.Format("update DateWash set UserID=null where DateStr='{0}'", dateStr);

                    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, conn, trans);
                    cmd.ExecuteNonQuery();


                    trans.Commit();
                }
                catch (Exception ee)
                {
                    trans.Rollback();
                    json.success = false;
                    json.msg     = ee.Message;
                    if (ee.InnerException != null)
                    {
                        json.msg += "  " + ee.InnerException.Message;
                    }
                }
            }


            json.success = true;
            json.msg     = "操作成功";
            return(Content(json.ToString()));
        }
コード例 #25
0
        public ActionResult CreateDateWashPerson()
        {
            int createCount = Request["createCount"].ToInt();

            string [] personList = Request["personList"].Split(',');
            string    startDate  = Request["startDate"];

            DBModel.ApartmentCashEntities ef = new DBModel.ApartmentCashEntities();

            System.Data.Entity.Database db = ef.Database;

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(db.Connection.ConnectionString))
            {
                conn.Open();
                System.Data.SqlClient.SqlTransaction trans = conn.BeginTransaction();

                try
                {
                    for (int i = 0; i < createCount; i++)
                    {
                        string userID  = personList[i % personList.Length];
                        string dateStr = DateTime.Parse(startDate).AddDays(i).ToString("yyyy-MM-dd");
                        string sql     = "update DateWash set UserID=@UserID where DateStr=@DateStr";

                        System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, conn, trans);
                        cmd.Parameters.AddWithValue("@UserID", userID);
                        cmd.Parameters.AddWithValue("@DateStr", dateStr);
                        cmd.ExecuteNonQuery();
                    }
                    trans.Commit();
                }
                catch (Exception ee)
                {
                    trans.Rollback();
                    json.success = false;
                    json.msg     = ee.Message;
                    if (ee.InnerException != null)
                    {
                        json.msg += "  " + ee.InnerException.Message;
                    }
                }
            }



            json.success = true;
            json.msg     = "生成成功";
            return(Content(json.ToString()));
        }
コード例 #26
0
        public bool Guardar(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario, int empresaTercerosID)
        {
            foreach (ConsolidadoGuias guiaConsolidado in this.guiasConsolidado)
            {
                GuiaEstadoHistorico oGuiaEstado = new GuiaEstadoHistorico();
                //GuiaEstadoHistoricoDatos oGuiaDatos = new GuiaEstadoHistoricoDatos();
                guiaConsolidado.ConsolidadoID = this.ConsolidadoID;                     //ID del Consolidado
                if (guiaConsolidado.Guardar(transaccion, empresaTercerosID))
                {
                    Config.Conexion.EjecutarSinResultados(transaccion, "GuiaEstadosHistoricosConsolidadoINS", guiaConsolidado.GuiaID, usuario.UsuarioID, agenciaUsuaria);

                    /*oGuiaEstado.GuiaID = guiaConsolidado.GuiaID;
                     * oGuiaEstado.EstadoGuiaID=(int)SisPack.ValorEstadoRedespacho.RedespachadaEmpresaTerceros;
                     * oGuiaEstado.TipoEstadoGuiaID= SisPack.TipoEstadoGuia.EstadoRedespacho;
                     * oGuiaEstado.UsuarioID=usuario.UsuarioID;
                     * oGuiaEstado.FechaHis= DateTime.Today;
                     * oGuiaEstado.AgenciaID= agenciaUsuaria;
                     * //oGuiaEstado.Observaciones = obs;
                     * oGuiaEstado.Observaciones = "";
                     * oGuiaEstado.Guardar(transaccion);
                     *
                     * GuiaEstadoHistorico guiaEstadoHistoricoMovimiento = new GuiaEstadoHistorico();
                     * guiaEstadoHistoricoMovimiento.AgenciaID = agenciaUsuaria;
                     * guiaEstadoHistoricoMovimiento.UsuarioID = usuario.UsuarioID;
                     * guiaEstadoHistoricoMovimiento.TipoEstadoGuiaID = SisPack.TipoEstadoGuia.EstadoMovimiento;
                     * guiaEstadoHistoricoMovimiento.EstadoGuiaID = (int)SisPack.ValorEstadoMovimiento.EnViaje;
                     * guiaEstadoHistoricoMovimiento.FechaHis =  DateTime.Today;
                     * guiaEstadoHistoricoMovimiento.GuiaID = guiaConsolidado.GuiaID;
                     * guiaEstadoHistoricoMovimiento.Guardar(transaccion);
                     *
                     * GuiaEstadoHistorico guiaEstadoHistoricoEstatico = new GuiaEstadoHistorico();
                     * guiaEstadoHistoricoEstatico.AgenciaID = agenciaUsuaria;
                     * guiaEstadoHistoricoEstatico.UsuarioID = usuario.UsuarioID;
                     * guiaEstadoHistoricoEstatico.TipoEstadoGuiaID = SisPack.TipoEstadoGuia.EstadoEstatico;
                     * guiaEstadoHistoricoEstatico.EstadoGuiaID = (int)SisPack.ValorEstadoEstatico.EnTransito;
                     * guiaEstadoHistoricoEstatico.FechaHis =  DateTime.Today;
                     * guiaEstadoHistoricoEstatico.GuiaID = guiaConsolidado.GuiaID;
                     * guiaEstadoHistoricoEstatico.Guardar(transaccion);*/
                }
                else
                {
                    transaccion.Rollback();
                    return(false);
                }

                //Config.Conexion.EjecutarSinResultados(transaccion,"GuiaEstadosHistoricosConsolidadoINS", this.ConsolidadoID, usuario.UsuarioID,agenciaUsuaria);
            }
            return(true);
        }
コード例 #27
0
 public bool Guardar(System.Data.SqlClient.SqlTransaction transaccion, IUsuarios usuario, bool validarStock)
 {
     foreach (GuiaUnidadLogisticaDetalle guiaUnidadLogistica in this.guiasUnidadesLogisticas)
     {
         GuiaEstadoHistorico      oGuiaEstado = new GuiaEstadoHistorico();
         GuiaEstadoHistoricoDatos oGuiaDatos  = new GuiaEstadoHistoricoDatos();
         guiaUnidadLogistica.GuiaID = this.GuiaID; //ID de la guía
         if (!guiaUnidadLogistica.Guardar(transaccion, validarStock))
         {
             transaccion.Rollback();
             return(false);
         }
     }
     return(true);
 }
コード例 #28
0
 public void ImporteRedespacho(System.Data.SqlClient.SqlTransaction transaccion, double kilajeSaca)
 {
     try
     {
         foreach (ConsolidadoGuias guiaConsolidado in this.guiasConsolidado)
         {
             guiaConsolidado.ConsolidadoID = ConsolidadoID;
             guiaConsolidado.ImporteRedespacho(transaccion, kilajeSaca);
         }
     }
     catch (Exception ex)
     {
         transaccion.Rollback();
         throw ex;
     }
 }
コード例 #29
0
ファイル: CCerereSQL.cs プロジェクト: iStomaLTD/iStoma-LTD
 /// <summary>
 /// Obtinem o conexiune deschisa cu o tranzactie
 /// </summary>
 /// <param name="transac"></param>
 /// <param name="DoCommit"></param>
 public static void CloseTransactionOnConnection(System.Data.SqlClient.SqlTransaction transac, bool DoCommit)
 {
     System.Data.SqlClient.SqlConnection cn = transac.Connection;
     if (cn != null)
     {
         if (DoCommit)
         {
             transac.Commit();
         }
         else
         {
             transac.Rollback();
         }
         transac.Dispose();
         cn.Close();
         cn.Dispose();
     }
 }
コード例 #30
0
        private void btnContinue_Click(object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlTransaction trnEnvelope = VPSConnection.BeginTransaction();

            myPLine.UtilisationLineId      = productionLineId;
            myPLine.UtilisationWorkDayDate = DateTime.Now;
            myPLine.UtilisationLineStarted = dtpStarted.Value.TimeOfDay;
            myPLine.UtilisationLineStopped = myPLine.DefaultStopTime;
            if (myPLine.Insert_Utilisation_Record(trnEnvelope) == true)
            {
                trnEnvelope.Commit();
                this.DialogResult = DialogResult.Yes;
                this.Hide();
            }
            else
            {
                trnEnvelope.Rollback();
            }
        }