Example #1
0
        public DataSet GetDatasetByCommand(string Command)
        {
            try
            {
                sqlCommand.CommandText    = Command;
                sqlCommand.CommandTimeout = commandTimeout;
                sqlCommand.CommandType    = CommandType.StoredProcedure;

                sqlConnection.Open();

                SqlDataAdapter adpt = new SqlDataAdapter(sqlCommand);
                DataSet        ds   = new DataSet();
                adpt.Fill(ds);
                return(ds);
            }
            catch (Exception ex)
            {
                NsUtility.SaveException(ex);
                return(null);
            }
            finally
            {
                CloseConnection();
            }
        }
Example #2
0
        public GetProductListResponse GetProductList(int pageNo, int pageSize, string searchKey = null, int?CategoryID = null)
        {
            GetProductListResponse _getProductListResponse = new GetProductListResponse();

            _getProductListResponse.ProductList = new List <Product>();
            try
            {
                SqlHelper sqlHelper = new SqlHelper();

                sqlHelper.AddSetParameterToSQLCommand("searchKey", SqlDbType.VarChar, searchKey);
                sqlHelper.AddSetParameterToSQLCommand("pageNo", SqlDbType.Int, pageNo);
                sqlHelper.AddSetParameterToSQLCommand("pageSize", SqlDbType.Int, pageSize);
                sqlHelper.AddSetParameterToSQLCommand("CategoryID", SqlDbType.Int, CategoryID);

                DataSet ds = sqlHelper.GetDatasetByCommand("Product_List");

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["DBSTATUS"].ToString() == "SUCCESS")
                            {
                                _getProductListResponse.TotalPages = Convert.ToInt32(
                                    ds.Tables[0].Rows[0]["TotalPages"].ToString());
                                _getProductListResponse.TotalRows = Convert.ToInt32(
                                    ds.Tables[0].Rows[0]["TotalRows"].ToString());

                                if (ds.Tables.Count > 1)
                                {
                                    _getProductListResponse.Status = ActivityStatus.SUCCESS;
                                    foreach (DataRow dr in ds.Tables[1].Rows)
                                    {
                                        _getProductListResponse.ProductList.Add(new Product
                                        {
                                            ID               = Convert.ToInt32(dr["ID"].ToString()),
                                            ProductCode      = dr["ProductCode"].ToString(),
                                            ProductName      = dr["ProductName"].ToString(),
                                            ShortName        = dr["ShortName"].ToString(),
                                            LongName         = dr["LongName"].ToString(),
                                            Details          = dr["Details"].ToString(),
                                            LongDescription  = dr["LongDescription"].ToString(),
                                            ShortDescription = dr["ShortDescription"].ToString(),

                                            Image1  = dr["Image1"].ToString(),
                                            Image2  = dr["Image2"].ToString(),
                                            Image3  = dr["Image3"].ToString(),
                                            UOMID   = Convert.ToInt32(dr["UOMID"].ToString()),
                                            BrandID = Convert.ToInt32(dr["BrandID"].ToString())
                                        });
                                    }
                                }
                                else
                                {
                                    _getProductListResponse.Status = ActivityStatus.NOROWS;
                                }
                            }
                            else
                            {
                                _getProductListResponse.Status = ActivityStatus.NOROWS;
                            }
                        }
                        else
                        {
                            _getProductListResponse.Status = ActivityStatus.ERROR;
                        }
                    }
                    else
                    {
                        _getProductListResponse.Status = ActivityStatus.ERROR;
                    }
                }
                else
                {
                    _getProductListResponse.Status = ActivityStatus.ERROR;
                }
            }
            catch (Exception ex)
            {
                NsUtility.SaveException(ex, "", "NsCommerce");
            }
            return(_getProductListResponse);
        }
Example #3
0
        public CreateProductResponse Create(string IPAddress = null, int?CreatedUserID = null)
        {
            CreateProductResponse _response = new CreateProductResponse();

            try
            {
                SqlHelper sqlHelper = new SqlHelper();

                sqlHelper.AddSetParameterToSQLCommand("ProductCode", SqlDbType.VarChar, this.ProductCode);
                sqlHelper.AddSetParameterToSQLCommand("ProductName", SqlDbType.NVarChar, this.ProductName);
                sqlHelper.AddSetParameterToSQLCommand("ShortName", SqlDbType.VarChar, this.ShortName);
                sqlHelper.AddSetParameterToSQLCommand("LongName", SqlDbType.NVarChar, this.LongName);
                sqlHelper.AddSetParameterToSQLCommand("Details", SqlDbType.NVarChar, this.Details);
                sqlHelper.AddSetParameterToSQLCommand("LongDescription", SqlDbType.NVarChar, this.LongDescription);
                sqlHelper.AddSetParameterToSQLCommand("ShortDescription", SqlDbType.NVarChar, this.ShortDescription);

                sqlHelper.AddSetParameterToSQLCommand("CreatedUserID", SqlDbType.Int, CreatedUserID);
                sqlHelper.AddSetParameterToSQLCommand("UOMID", SqlDbType.Int, this.UOMID);
                sqlHelper.AddSetParameterToSQLCommand("BrandID", SqlDbType.Int, this.BrandID);
                sqlHelper.AddSetParameterToSQLCommand("IPAddress", SqlDbType.VarChar, IPAddress);

                DataSet ds = sqlHelper.GetDatasetByCommand("Product_Create");

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["DBSTATUS"].ToString() == "SUCCESS")
                            {
                                if (ds.Tables.Count > 1)
                                {
                                    if (ds.Tables[1].Rows.Count > 0)
                                    {
                                        _response.Status = ActivityStatus.SUCCESS;
                                        _response.ID     = Convert.ToInt32(ds.Tables[1].Rows[0]["ID"].ToString());
                                    }
                                }
                            }
                            else if (ds.Tables[0].Rows[0]["DBSTATUS"].ToString() == "DUPLICATE")
                            {
                                _response.Status = ActivityStatus.DUPLICATE;
                            }
                            else
                            {
                                _response.Status = ActivityStatus.ERROR;
                            }
                        }
                        else
                        {
                            _response.Status = ActivityStatus.ERROR;
                        }
                    }
                    else
                    {
                        _response.Status = ActivityStatus.ERROR;
                    }
                }
                else
                {
                    _response.Status = ActivityStatus.ERROR;
                }
            }
            catch (Exception ex)
            {
                _response.Status = ActivityStatus.EXCEPTION;
                NsUtility.SaveException(ex, "", "NsCommerce");
            }

            return(_response);
        }