/// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public DbDataReader ExecuteSelect(string query)
        {
            DbConnection dbConnection = dataBaseFactory.GetConnection();

            dbConnection.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            DbCommand command = dataBaseFactory.GetCommand();

            command.Connection  = dbConnection;
            command.CommandType = CommandType.Text;
            command.CommandText = query;
            dbConnection.Open();
            return(command.ExecuteReader(CommandBehavior.CloseConnection));
        }
예제 #2
0
        public List <MyAgency> InsertAgencyMaster(MyAgency Data)
        {
            DbConnection  con = null;
            DbTransaction trans;

            try
            {
                con = _dbFactory.GetConnection();
                con.Open();
                trans = _dbFactory.GetTransaction(con);
                DbCommand Cmd = _dbFactory.GetCommand();
                Cmd.Connection  = con;
                Cmd.Transaction = trans;

                try
                {
                    Cmd.CommandText = " IF((select count(*) from NVO_AgencyMaster where ID=@ID)<=0) " +
                                      " BEGIN " +
                                      " INSERT INTO  NVO_AgencyMaster(AgencyName,AgencyCode,CountryID,CityID,StateID,TaxGSTNo,OrganizationType,OwnOffice,DocumentSuffix,RegPanNO,Status,Address,Notes) " +
                                      " values (@AgencyName,@AgencyCode,@CountryID,@CityID,@StateID,@TaxGSTNo,@OrganizationType,@OwnOffice,@DocumentSuffix,@RegPanNO,@Status,@Address,@Notes) " +
                                      " END  " +
                                      " ELSE " +
                                      " UPDATE NVO_AgencyMaster SET AgencyName=@AgencyName,AgencyCode=@AgencyCode,CountryID=@CountryID,CityID=@CityID,StateID=@StateID,TaxGSTNo=@TaxGSTNo,OrganizationType=@OrganizationType,OwnOffice=@OwnOffice,DocumentSuffix=@DocumentSuffix,RegPanNO=@RegPanNO,Status=@Status,Address=@Address,Notes=@Notes where ID=@ID";

                    Cmd.Parameters.Add(_dbFactory.GetParameter("@ID", Data.ID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@AgencyName", Data.AgencyName));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@AgencyCode", Data.AgencyCode));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@CountryID", Data.CountryID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@CityID", Data.CityID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@StateID", Data.StateID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@TaxGSTNo", Data.TaxGSTNo));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@OwnOffice", Data.OwnOffice));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@DocumentSuffix", Data.DocumentSuffix));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@OrganizationType", Data.OrganizationType));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@RegPanNO", Data.RegPanNO));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Status", Data.Status));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Address", Data.Address));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Notes", Data.Notes));
                    int result = Cmd.ExecuteNonQuery();

                    Cmd.CommandText = "select ident_current('NVO_AgencyMaster')";
                    if (Data.ID == 0)
                    {
                        Data.ID = Int32.Parse(Cmd.ExecuteScalar().ToString());
                    }
                    else
                    {
                        Data.ID = Data.ID;
                    }

                    trans.Commit();
                    return(ListAgency);
                }
                catch (Exception ex)
                {
                    string ss = ex.ToString();
                    trans.Rollback();
                    return(ListAgency);
                }
            }


            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (con != null && con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }
예제 #3
0
        public List <MyDataBusinessLogic> InsertUserMaster(MyDataBusinessLogic Data)
        {
            int           r1  = 0;
            int           r2  = 0;
            DbConnection  con = null;
            DbTransaction trans;

            try
            {
                con = _dbFactory.GetConnection();
                con.Open();
                trans = _dbFactory.GetTransaction(con);
                DbCommand Cmd = _dbFactory.GetCommand();
                Cmd.Connection  = con;
                Cmd.Transaction = trans;

                try
                {
                    Cmd.CommandText = " IF((select count(*) from NVO_Reg where ID=@ID)<=0) " +
                                      " BEGIN " +
                                      " INSERT INTO  NVO_Reg(Name,Mobile,Email,UserName,Password,UserCode,Location,Designation,Branch,Address,CurrentDate) " +
                                      " values (@Name,@Mobile,@Email,@UserName,@Password,@UserCode,@Location,@Designation,@Branch,@Address,@CurrentDate) " +
                                      " END  " +
                                      " ELSE " +
                                      " UPDATE NVO_Reg SET Name=@Name,Mobile=@Mobile,Email=@Email,UserName=@UserName,Password=@Password,UserCode=@UserCode,Location=@Location,Designation=@Designation,Branch=@Branch,Address=@Address,CurrentDate=@CurrentDate where ID=@ID";

                    Cmd.Parameters.Add(_dbFactory.GetParameter("@ID", Data.ID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Name", Data.Name));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Mobile", Data.MobileNo));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Email", Data.Email));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@UserName", Data.UserName));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Password", Data.Password));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@UserCode", Data.UserCode));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Location", Data.Location));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Designation", Data.Designation));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Branch", Data.Branch));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Address", Data.Address));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@CurrentDate", System.DateTime.Now));

                    int result = Cmd.ExecuteNonQuery();

                    Cmd.CommandText = "select ident_current('NVO_Reg')";
                    if (Data.ID == 0)
                    {
                        Data.ID = Int32.Parse(Cmd.ExecuteScalar().ToString());
                    }
                    else
                    {
                        Data.ID = Data.ID;
                    }

                    trans.Commit();
                    return(List);
                }
                catch (Exception ex)
                {
                    string ss = ex.ToString();
                    trans.Rollback();
                    return(List);
                }
            }


            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (con != null && con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }
예제 #4
0
        public List <MyCountry> InsertCountryMaster(MyCountry Data)
        {
            DbConnection  con = null;
            DbTransaction trans;

            try
            {
                con = _dbFactory.GetConnection();
                con.Open();
                trans = _dbFactory.GetTransaction(con);
                DbCommand Cmd = _dbFactory.GetCommand();
                Cmd.Connection  = con;
                Cmd.Transaction = trans;

                try
                {
                    Cmd.CommandText = " IF((select count(*) from NVO_CountryMaster where ID=@ID)<=0) " +
                                      " BEGIN " +
                                      " INSERT INTO  NVO_CountryMaster(CountryCode,CountryName,Status) " +
                                      " values (@CountryCode,@CountryName,@Status) " +
                                      " END  " +
                                      " ELSE " +
                                      " UPDATE NVO_CountryMaster SET CountryCode=@CountryCode,CountryName=@CountryName,Status=@Status where ID=@ID";

                    Cmd.Parameters.Add(_dbFactory.GetParameter("@ID", Data.ID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@CountryCode", Data.CountryCode));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@CountryName", Data.CountryName));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Status", Data.Status));

                    int result = Cmd.ExecuteNonQuery();

                    Cmd.CommandText = "select ident_current('NVO_CountryMaster')";
                    if (Data.ID == 0)
                    {
                        Data.ID = Int32.Parse(Cmd.ExecuteScalar().ToString());
                    }
                    else
                    {
                        Data.ID = Data.ID;
                    }

                    trans.Commit();
                    return(ListCountry);
                }
                catch (Exception ex)
                {
                    string ss = ex.ToString();
                    trans.Rollback();
                    return(ListCountry);
                }
            }


            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (con != null && con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }