Example #1
0
 public HttpResponseMessage Update(SpecializationViewModel specializationViewModel)
 {
     try
     {
         var user = UserMatching.IsUserMatch();
         if (user == null)
         {
             responseSpecialization.UnAuthorized();
             return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseSpecialization, contentType));
         }
         specializationViewModel.UpdatedBy         = user.Id;
         specializationViewModel.IsInternalCreated = user.IsInternalUser;
         SqlParameter[] sqlParameters;
         string         parameter = SQLParameters.GetParameters <SpecializationViewModel>(specializationViewModel);
         sqlParameters = SQLParameters.GetSQLParameters <SpecializationViewModel>(specializationViewModel, "Update").ToArray();
         var specialization = unitOfWork.GetRepositoryInstance <object>().WriteStoredProcedure("Specialization_Detail " + parameter, sqlParameters);
         responseSpecialization.Success((new JavaScriptSerializer()).Serialize(specializationViewModel));
         return(Request.CreateResponse(HttpStatusCode.Accepted, responseSpecialization, contentType));
     }
     catch (Exception exception)
     {
         responseSpecialization.Exception(exception.Message);
         return(Request.CreateResponse(HttpStatusCode.Conflict, responseSpecialization, contentType));
     }
 }
Example #2
0
        public void Payment(PaymentModel payment)
        {
            DataTable dtb = new DataTable();

            dtb.Columns.Add(new DataColumn("OrganizationId", typeof(int)));
            dtb.Columns.Add(new DataColumn("ProductId", typeof(int)));
            dtb.Columns.Add(new DataColumn("Quantity", typeof(int)));
            dtb.Columns.Add(new DataColumn("Price", typeof(decimal)));

            foreach (var item in payment.ListPaymentDetail)
            {
                var dr = dtb.NewRow();
                dr["OrganizationId"] = item.OrganizationId;
                dr["ProductId"]      = item.ProductId;
                dr["Quantity"]       = item.Quantity;
                dr["Price"]          = item.Price;
                dtb.Rows.Add(dr);
            }

            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_AccountId", payment.Payment.AccountId);
            sqlParams.Add_Parameter("@_PaymentCode", payment.Payment.PaymentCode);
            sqlParams.Add_Parameter("@_ListPayment", dtb);
            _db.ExecuteNonQuery("usp_Payment_InsertOrUpdate", sqlParams, ExecuteType.StoredProcedure);
        }
Example #3
0
 /// <summary>
 /// Eliminar registro de manera dinámica al catalogo indicado a travez de una consulta sQL parametrizada
 /// </summary>
 /// <param name="sqlParameters"></param>
 /// <returns></returns>
 public ResultJson EliminarCEMantenimiento(SQLParameters sqlParameters)
 {
     try
     {
         using (Model.DbContextJulio db = new Model.DbContextJulio())
         {
             userId   = db.AspNetUsers.Where(s => s.UserName == sqlParameters.userName).FirstOrDefault().Id;
             querySQL = $"DELETE {sqlParameters.tableName} WHERE ";
             List <SqlParameter> parameters = new List <SqlParameter>();
             foreach (var columna in sqlParameters.Columns)
             {
                 parameters.Add(new SqlParameter($"@{columna.Name}", darFormato(columna)));
                 querySQL += $"{columna.Name} = @{columna.Name}";
             }
             //Ejecutamos la consulta sql y con los parametros que necesita, si todo es correcto nos devolvera el nuemero de registros que fue actualizado
             int noOfRowInserted = db.Database.ExecuteSqlCommand(querySQL, parameters.ToArray());
         }
         return(result);
     }
     catch (Exception ex)
     {
         result.Success        = false;
         result.Message        = "Error en la transacción, vuelva intentarlo mas tarde";
         result.InnerException = $"{ex.Message}";
         return(result);
     }
 }
Example #4
0
        public void ExecuteNonQuery(string query, SQLParameters parameter, ExecuteType type)
        {
            using (var conn = new SqlConnection(_connectionString))
            {
                try
                {
                    conn.Open();

                    var cmd = new SqlCommand();
                    cmd.Connection     = conn;
                    cmd.CommandType    = type == ExecuteType.StoredProcedure ? CommandType.StoredProcedure : CommandType.Text;
                    cmd.CommandText    = query;
                    cmd.CommandTimeout = _connectDbTimeOut;

                    if (parameter != null)
                    {
                        cmd.Parameters.AddRange(parameter.ToArray());
                    }

                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (conn.State != ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }
        }
Example #5
0
        public T ExecuteScalarFunction <T>(string query, SQLParameters parameter, ExecuteType type)
        {
            using (_con = new SqlConnection(ConnectionString))
            {
                _cmd = new SqlCommand {
                    Connection = _con
                };
                _cmd.Parameters.Clear();
                _cmd.CommandType    = type == ExecuteType.StoredProcedure ? CommandType.StoredProcedure : CommandType.Text;
                _cmd.CommandText    = query;
                _cmd.CommandTimeout = ConnectDbTimeOut;

                if (parameter != null)
                {
                    _cmd.Parameters.AddRange(parameter.ToArray());
                }
                SqlParameter returnValue = _cmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Text);
                returnValue.Direction = ParameterDirection.ReturnValue;

                _con.Open();
                _cmd.ExecuteNonQuery();
                if (_con.State == ConnectionState.Open)
                {
                    _con.Close();
                }

                return((T)returnValue.Value);
            }
        }
Example #6
0
            public parameters(char ch)
            {
                //log = new logger();
                var settings = new System.Collections.Specialized.NameValueCollection();

                try
                {
                    settings = System.Configuration.ConfigurationManager.GetSection(ch.ToString()) as System.Collections.Specialized.NameValueCollection;
                    SQLdbConnectionstring = settings["ConnectionString"];
                    extracting_directory  = settings["ExtractedDir"];
                    connection            = new SqlConnection(SQLdbConnectionstring);
                    sqlcmd            = new SqlCommand();
                    sqlcmd.Connection = connection;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Logger.Error(e);
                    //log.Add(e.ToString());
                }

                sqlParameters = new SQLParameters();
                sqlParameters.sqlBulkCopyBatchSize = Properties.Settings.Default.SqlBulkCopyBatchSize;
                sqlParameters.sqlConnectionString  = SQLdbConnectionstring;

                destination         = shared_directory + extracting_directory + extension;
                extract_destination = shared_directory + extracting_directory;
                ended_dir           = extract_destination + extracting_directory;

                separator     = Convert.ToChar(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                antiseparator = separator == ',' ? '.' : ',';
            }
Example #7
0
        /// <summary>
        /// Agregar registro de manera dinámica al catalogo indicado a travez de una consulta SQL parametrizada
        /// </summary>
        /// <param name="sqlParameters"></param>
        /// <returns></returns>
        public ResultJson AgregarMantenimiento(SQLParameters sqlParameters)
        {
            try
            {
                using (Model.DbContextJulio ctx = new Model.DbContextJulio())
                {
                    userId   = ctx.AspNetUsers.Where(s => s.UserName == sqlParameters.userName).FirstOrDefault().Id;
                    querySQL = $"INSERT INTO {sqlParameters.tableName} (";

                    List <SqlParameter> parameters = new List <SqlParameter>();
                    foreach (var columna in sqlParameters.Columns)
                    {
                        parameters.Add(new SqlParameter($"@{columna.Name}", darFormato(columna)));
                        querySQL    += $"{columna.Name},";
                        queryValues += $"@{columna.Name},";
                    }
                    querySQL = $"{querySQL.TrimEnd(',')}) Values({queryValues.TrimEnd(',')})";
                    //Ejecutamos la consulta SQL con los parametros necesarios, si todo es correcto nos devolvera el numero de registros que fueron registrados
                    int noOfRowInserted = ctx.Database.ExecuteSqlCommand(querySQL, parameters.ToArray());
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.Success        = false;
                result.Message        = "Error en la transacción, vuelva intentarlo mas tarde";
                result.InnerException = $"{ex.Message}";
                return(result);
            }
        }
Example #8
0
        public DataTable ExecuteToTable(string query, SQLParameters parameter, ExecuteType type)
        {
            using (_con = new SqlConnection(ConnectionString))
            {
                _con.Open();
                _cmd = new SqlCommand {
                    Connection = _con
                };
                _cmd.Parameters.Clear();
                _cmd.CommandType    = type == ExecuteType.StoredProcedure ? CommandType.StoredProcedure : CommandType.Text;
                _cmd.CommandText    = query;
                _cmd.CommandTimeout = ConnectDbTimeOut;

                if (parameter != null)
                {
                    _cmd.Parameters.AddRange(parameter.ToArray());
                }

                _adapter = new SqlDataAdapter(_cmd);
                DataTable tbl = new DataTable();
                _adapter.Fill(tbl);
                _adapter.Dispose();

                if (_con.State == ConnectionState.Open)
                {
                    _con.Close();
                }

                return(tbl);
            }
        }
Example #9
0
        public void ExecuteNonQuery(string query, SQLParameters parameter, ExecuteType type)
        {
            using (_con = new SqlConnection(ConnectionString))
            {
                _con.Open();
                _cmd = new SqlCommand
                {
                    Connection     = _con,
                    CommandType    = type == ExecuteType.StoredProcedure ? CommandType.StoredProcedure : CommandType.Text,
                    CommandText    = query,
                    CommandTimeout = ConnectDbTimeOut
                };

                if (parameter != null)
                {
                    _cmd.Parameters.AddRange(parameter.ToArray());
                }

                _cmd.ExecuteNonQuery();
                _con.Dispose();

                if (_con.State == ConnectionState.Open)
                {
                    _con.Close();
                }
            }
        }
Example #10
0
        public async Task <List <Account> > GetListInforAccount(List <int> listUser)
        {
            DataTable dtb = new DataTable();

            dtb.Columns.Add(new DataColumn("KeyId"));

            foreach (var item in listUser)
            {
                var dr = dtb.NewRow();
                dr["KeyId"] = item;
                dtb.Rows.Add(dr);
            }

            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ListAccount", dtb);

            var tbl = _db.ExecuteToTable("usp_Account_GetListInfor", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            List <Account> listAccount = new List <Account>();

            listAccount = tbl != null ? AutoMapper <Account> .Map(tbl) : listAccount;

            return(listAccount);
        }
        public async Task <List <Product> > Shop_GetListProduct(List <Product> listProduct)
        {
            DataTable dtb = new DataTable();

            dtb.Columns.Add("ProductId", typeof(int));

            foreach (var item in listProduct)
            {
                var dr = dtb.NewRow();
                dr[0] = item.ProductId;
                dtb.Rows.Add(dr);
            }

            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ListProduct", dtb);
            var tbl = _db.ExecuteToTable("usp_Shop_GetListProduct", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            List <Product> listProductResult = new List <Product>();

            listProductResult = (tbl != null && tbl.Rows.Count > 0) ? AutoMapper <Product> .Map(tbl) : listProductResult;

            return(listProductResult);
        }
Example #12
0
        public HttpResponseMessage GetById(int id)
        {
            try
            {
                var doctorViewModel = new DoctorViewModel();
                doctorViewModel.Id = id;
                if (UserMatching.IsUserMatch() == null)
                {
                    responseDoctor.UnAuthorized();
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseDoctor, contentType));
                }

                SqlParameter[] sqlParameters;
                string         parameter = SQLParameters.GetParameters <DoctorViewModel>(doctorViewModel);
                sqlParameters = SQLParameters.GetSQLParameters <DoctorViewModel>(doctorViewModel, "GetById").ToArray();
                var doctor = unitOfWork.GetRepositoryInstance <DoctorViewModel>().ReadStoredProcedure("Doctor_Detail " + parameter, sqlParameters).ToList();
                responseDoctor.Success((new JavaScriptSerializer()).Serialize(doctor));
                return(Request.CreateResponse(HttpStatusCode.Accepted, responseDoctor, contentType));
            }
            catch (Exception exception)
            {
                responseDoctor.Exception(exception.Message);
                return(Request.CreateResponse(HttpStatusCode.Conflict, responseDoctor, contentType));
            }
        }
Example #13
0
        public HttpResponseMessage Add(DoctorViewModel doctorViewModel)
        {
            try
            {
                var user = UserMatching.IsUserMatch();
                if (user == null)
                {
                    responseDoctor.UnAuthorized();
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseDoctor, contentType));
                }
                doctorViewModel.IsInternalCreated = user.IsInternalUser;
                doctorViewModel.CreatedBy         = user.Id;
                SqlParameter[] sqlParameters;
                string         parameter = SQLParameters.GetParameters <DoctorViewModel>(doctorViewModel);
                sqlParameters = SQLParameters.GetSQLParameters <DoctorViewModel>(doctorViewModel, "Add").ToArray();
                var result = unitOfWork.GetRepositoryInstance <object>().WriteStoredProcedure("Doctor_Detail " + parameter, sqlParameters);
                if (result >= 1)
                {
                    responseDoctor.Success((new JavaScriptSerializer()).Serialize(result));
                }
                else
                {
                    responseDoctor.Failed((new JavaScriptSerializer()).Serialize(doctorViewModel), "Failed to add doctor detail, please try again");
                }

                return(Request.CreateResponse(HttpStatusCode.Accepted, responseDoctor, contentType));
            }
            catch (Exception exception)
            {
                responseDoctor.Exception(exception.Message);
                return(Request.CreateResponse(HttpStatusCode.Conflict, responseDoctor, contentType));
            }
        }
Example #14
0
        /*---------------------------------
         *	PROCEDURE procLIS_SearchStaticText
         *---------------------------------
         * @IdResource int,
         * @IdLanguage int,
         * @Context ntext,
         * @Description nvarchar 300
         */
        public Boolean ListSearchStaticText(SQLParameters Parameters, out DataSet dsSearchStaticText)
        {
            dsSearchStaticText = new DataSet();

            SqlCommand CommandListSearchStaticText = new SqlCommand("procLIS_SearchStaticText", Database.Connection);

            if (CommandListSearchStaticText == null)
            {
                return(false);
            }

            try
            {
                CommandListSearchStaticText.CommandType = CommandType.StoredProcedure;
                Parameters.FillParametersIn(CommandListSearchStaticText);

                SqlDataAdapter AdapterListSearchStaticText = new SqlDataAdapter();
                AdapterListSearchStaticText.SelectCommand = CommandListSearchStaticText;

                AdapterListSearchStaticText.Fill(dsSearchStaticText, "tblStaticText");
            }
            catch (SqlException Ex)
            {
                throw new SQLException("Error in 'ListSearchStaticText' function", Ex);
            }

            return(true);
        }
Example #15
0
        /*[dbo].[procLIS_ActiveLanguages]
         */
        public Boolean ListActiveLanguages(out DataSet dsLanguages)
        {
            dsLanguages = new DataSet();

            SQLParameters Parameters = new SQLParameters();

            SqlCommand CommandSelectAllLanguages = new SqlCommand("procLIS_ActiveLanguages", Database.Connection);

            if (CommandSelectAllLanguages == null)
            {
                return(false);
            }

            try
            {
                CommandSelectAllLanguages.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter AdapterSelectAllLanguages = new SqlDataAdapter();

                AdapterSelectAllLanguages.SelectCommand = CommandSelectAllLanguages;

                dsLanguages.DataSetName = "Languages";

                AdapterSelectAllLanguages.Fill(dsLanguages, "Languages");
            }
            catch (SqlException Ex)
            {
                throw new SQLException("Exception in 'ListActiveLanguages' function!", Ex);
            }
            catch (FormatException Ex)
            {
                throw new SQLException("Exception in 'ListActiveLanguages' function!", Ex);
            }
            return(true);
        }
Example #16
0
 public SQLDeviceCursor
 (
     SQLDeviceSession deviceSession,
     SelectStatement statement,
     bool isAggregate,
     SQLParameters parameters,
     int[] keyIndexes,
     SQLScalarType[] keyTypes,
     SQLParameters keyParameters,
     SQLLockType lockType,
     SQLCursorType cursorType,
     SQLIsolationLevel isolationLevel
 ) : base()
 {
     _deviceSession        = deviceSession;
     _statement            = statement;
     _isAggregate          = isAggregate;
     _originalWhereClause  = _statement.QueryExpression.SelectExpression.WhereClause;
     _originalHavingClause = _statement.QueryExpression.SelectExpression.HavingClause;
     _originalParameters   = parameters;
     _parameters           = new SQLParameters();
     _parameters.AddRange(parameters);
     _keyIndexes     = keyIndexes;
     _keyTypes       = keyTypes;
     _keyParameters  = keyParameters;
     _lockType       = lockType;
     _cursorType     = cursorType;
     _isolationLevel = isolationLevel;
     EnsureConnection();
     _isDeferred = new bool[ColumnCount];
     for (int index = 0; index < ColumnCount; index++)
     {
         _isDeferred[index] = _cursor.IsDeferred(index);
     }
 }
Example #17
0
        public int GetCountOrder()
        {
            SQLParameters p      = new SQLParameters();
            int           result = _db.ExecuteScalarFunction <int>("ufn_Test", p, ExecuteType.StoredProcedure);

            return(result);
        }
        public void DeleteProduct(int productId)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ProductId", productId);

            _db.ExecuteNonQuery("usp_Product_Delete", sqlParams, ExecuteType.StoredProcedure);
        }
Example #19
0
        static void Main(string[] args)
        {
            //Зададим параметры логгирования для SQLHelper, Writer, Reader
            SQLHelper.BeginSomeError     += PrintLog;        //Делегат для определения формы логирования
            SQLHelper.BeginSomeStep      += PrintLog;        //Делегат для определения формы логирования
            SQLHelper.BeginSomeIteration += PrintLog;        //Делегат для определения формы логирования
            Reader.BeginSomeError        += PrintLog;        //Делегат для определения формы логирования
            Reader.BeginSomeStep         += PrintLog;        //Делегат для определения формы логирования
            Reader.BeginSomeIteration    += PrintNotLineLog; //Делегат для определения формы логирования
            Writer.BeginSomeStep         += PrintLog;        //Делегат для определения формы логирования

            //Установим параметры SQL
            SQLParameters sqlParameters = new SQLParameters();

            sqlParameters.sqlBulkCopyBatchSize = 50000;
            sqlParameters.sqlConnectionString  = @"Data Source=Servertest01;Initial Catalog=test_DB_for_MRK;Integrated Security=True";


            //////ИМПОРТ В SQL
            string[] files = Directory.GetFiles(@"c:\SKLAD\", "*.DBF", SearchOption.TopDirectoryOnly);
            try
            {
                foreach (string file in files)
                {
                    int i;
                    if (file == "PLAN")
                    {
                        i = 0;
                    }
                    dbfCoreDLL.dbfHelper.Reader.dataTableMaxRows = 1000000;
                    dbfCoreDLL.dbfHelper.Reader.sqlParameters    = sqlParameters;
                    try
                    {
                        dbfCoreDLL.dbfHelper.Reader.ReadDBF(file);
                    }
                    catch
                    {
                        i = 0;
                    }
                }
            }
            catch
            {
                throw;
            }
            //dbfCoreDLL.dbfHelper.Reader.dataTableMaxRows = 1000000;
            //dbfCoreDLL.dbfHelper.Reader.sqlParameters = sqlParameters;
            //dbfCoreDLL.dbfHelper.Reader.ReadDBF(@"U:\OPPO\DOS\PEO\PLAN\2017\171103\PLAN\PLAN.dbf");

            ////ЗАПИСЬ В DBF
            //sqlParameters.sqlTableName = "dbo.NA";
            //string templateFile = @"c:\WORK\dbf\NA1.DBF";
            //string outputFile = @"c:\WORK\dbf\NA_output.DBF";
            //dbfCoreDLL.dbfHelper.Writer.sqlParameters = sqlParameters;
            //dbfCoreDLL.dbfHelper.Writer.WriteDBF(templateFile, outputFile);
        }
Example #20
0
        public bool IsValidAccount(string email, string passWord)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_Account", email);
            sqlParams.Add_Parameter("@_Password", passWord);

            var tbl = _db.ExecuteToTable("usp_Account_CheckLogin", sqlParams, ExecuteType.StoredProcedure);

            return(tbl != null && tbl.Rows.Count > 0);
        }
        public void AddPrice(ProductPrice price)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_PriceId", price.PriceId);
            sqlParams.Add_Parameter("@_ProductCategoryId", price.ProductCategoryId);
            sqlParams.Add_Parameter("@_ProductId", price.ProductId);
            sqlParams.Add_Parameter("@_Date", price.Date);
            sqlParams.Add_Parameter("@_Amount", price.Amount);

            _db.ExecuteNonQuery("usp_Price_InsertOrUpdate", sqlParams, ExecuteType.StoredProcedure);
        }
Example #22
0
        public async Task <List <ProductCategory> > GetListProductCategory()
        {
            SQLParameters sqlParams = new SQLParameters();
            var           tbl       = _db.ExecuteToTable("usp_ProductCategory_GetList", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            List <ProductCategory> listProductCtg = new List <ProductCategory>();

            listProductCtg = (tbl != null && tbl.Rows.Count > 0) ? AutoMapper <ProductCategory> .Map(tbl) : listProductCtg;

            return(listProductCtg);
        }
Example #23
0
        public async Task <bool> CheckExistAccount(string email)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_Account", email);

            var tbl = _db.ExecuteToTable("usp_Account_CheckExistAccount", sqlParams, ExecuteType.StoredProcedure);

            await Task.FromResult(tbl);

            return(tbl != null && tbl.Rows.Count > 0);
        }
Example #24
0
        public void Insert(string sQuery, SQLParameters ArrayParameters)
        {
            bdCommand            = bdProvFact.CreateCommand();
            bdCommand.Connection = bdConnection;

            if (blnIsTransaction)
            {
                bdCommand.Transaction = bdTransaction;
            }

            try
            {
                for (int IntIndice = 0; IntIndice <= ArrayParameters.Count; IntIndice++)
                {
                    bdParameter = bdProvFact.CreateParameter();
                    bdParameter.ParameterName = (sDbProvider.Contains("OracleClient") ? ArrayParameters.arrayParameters[IntIndice, 0].Replace("@", ":") : ArrayParameters.arrayParameters[IntIndice, 0]);

                    if (sDbProvider.Contains("SqlClient"))
                    {
                        bdParameter.DbType = DBConvertSQLDataType(ArrayParameters.arrayParameters[IntIndice, 2]);
                    }
                    else
                    {
                        if (sDbProvider.Contains("OracleClient"))
                        {
                            sQuery             = sQuery.Replace("@", ":");
                            bdParameter.DbType = DBConvertORADataType(ArrayParameters.arrayParameters[IntIndice, 2]);
                        }
                    }
                    pReturnQuery = ArrayParameters.arrayParameters[IntIndice, 1];
                    pReturnQuery = pReturnQuery + "<br>";
                    if (ArrayParameters.arrayParameters[IntIndice, 1] == null || bdParameter.DbType == DbType.Object)
                    {
                        bdParameter.Value = DBNull.Value;
                    }
                    else
                    {
                        bdParameter.Value = ArrayParameters.arrayParameters[IntIndice, 1];
                    }
                    bdCommand.Parameters.Add(bdParameter);
                }

                bdCommand.CommandTimeout = iCommandTimeout;
                bdCommand.CommandText    = sQuery;
                //pReturnQuery = sQuery;
                bdCommand.ExecuteNonQuery();
            }
            catch (DbException dbEx)
            {
                //pReturnQuery = sQuery;
                sError = dbEx.ErrorCode + " " + dbEx.Message + "\t" + GetType().Name + "." + MethodBase.GetCurrentMethod().Name;
            }
        }
        public void AddOrganization(Organization ogt)
        {
            SQLParameters p = new SQLParameters();

            p.Add_Parameter("@_OrganizationId", ogt.OrganizationId);
            p.Add_Parameter("@_AccountId", ogt.AccountId);
            p.Add_Parameter("@_Name", ogt.Name);
            p.Add_Parameter("@_Phone", ogt.Phone);
            p.Add_Parameter("@_UrlLogo", ogt.UrlLogo);
            p.Add_Parameter("@_Address", ogt.Address);

            _db.ExecuteNonQuery("usp_Organization_InsertOrUpdate", p, ExecuteType.StoredProcedure);
        }
        public async Task <Product> GetInforProduct(int productId)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ProductId", productId);
            var tbl = _db.ExecuteToTable("usp_Product_GetInfor", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            Product product = new Product();

            product = (tbl != null && tbl.Rows.Count > 0) ? AutoMapper <Product> .Map(tbl.Rows[0]) : product;

            return(product);
        }
        public void AddProduct(Product product)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ProductId", product.ProductId);
            sqlParams.Add_Parameter("@_ProductCategoryId", product.ProductCategoryId);
            sqlParams.Add_Parameter("@_OrganizationId", product.OrganizationId);
            sqlParams.Add_Parameter("@_Code", product.Code);
            sqlParams.Add_Parameter("@_Name", product.Name);
            sqlParams.Add_Parameter("@_UrlPicture", product.UrlPicture);
            sqlParams.Add_Parameter("@_Description", product.Description);

            _db.ExecuteNonQuery("usp_Product_InsertOrUpdate", sqlParams, ExecuteType.StoredProcedure);
        }
Example #28
0
        public void CreateAccount(Account acc)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_AccountId", acc.AccountId);
            sqlParams.Add_Parameter("@_Email", acc.Email);
            sqlParams.Add_Parameter("@_Firstname", acc.Firstname);
            sqlParams.Add_Parameter("@_LastName", acc.LastName);
            sqlParams.Add_Parameter("@_Password", acc.Password);
            sqlParams.Add_Parameter("@_Phone", acc.Phone);
            sqlParams.Add_Parameter("@_Address", acc.Address);

            _db.ExecuteNonQuery("usp_Account_Create", sqlParams, ExecuteType.StoredProcedure);
        }
        public async Task <List <Product> > GetListProduct(int productCategoryId, int organizationId)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ProductCategoryId", productCategoryId);
            sqlParams.Add_Parameter("@_OrganizationId", organizationId);
            var tbl = _db.ExecuteToTable("usp_Product_GetList", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            List <Product> listProduct = new List <Product>();

            listProduct = (tbl != null && tbl.Rows.Count > 0) ? AutoMapper <Product> .Map(tbl) : listProduct;

            return(listProduct);
        }
        public async Task <Organization> GetInforOrganizationFromAcc(int accountId)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_AccountId", accountId);

            var tbl = _db.ExecuteToTable("usp_Organization_GetInforFromAcc", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            Organization ogt = new Organization();

            ogt = (tbl != null && tbl.Rows.Count > 0) ? AutoMapper <Organization> .Map(tbl.Rows[0]) : ogt;

            return(ogt);
        }