Example #1
0
        public HttpResponseMessage Add()
        {
            bal = new M_RegionBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            M_RegionDTO dto = null;

            response.statusCode = false;
            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <M_RegionDTO>();
                string UserID = context.Request.Form["UserID"];
                if (ObjUtil.isEmpty(UserID))
                {
                    throw new Exception("UserID is require");
                }
                dto.CreateBy = UserID;
                dto.UpdateBy = UserID;

                logger.debug("Add dto:" + dto.ToString());
                response.statusCode = bal.Add(dto);
            }
            catch (Exception ex)
            {
                logger.error("Add error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
Example #2
0
        public HttpResponseMessage Delete()
        {
            bal = new M_RegionBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            M_RegionDTO dto = null;

            response.statusCode = false;
            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <M_RegionDTO>();

                logger.debug("Delete dto:" + dto.ToString());
                response.statusCode = bal.Delete(dto);
            }
            catch (Exception ex)
            {
                logger.error("Delete error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
Example #3
0
        public HttpResponseMessage Select()
        {
            bal = new M_RegionBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;
            List <Select2DTO>   dataList   = new List <Select2DTO>();

            M_RegionDTO dto = null;

            response.statusCode = false;
            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <M_RegionDTO>();

                logger.debug("Select dto:" + dto.ToString());
                dataList            = bal.Select2ByObjList(dto);
                response.statusCode = true;
                response.data       = dataList;
            }
            catch (Exception ex)
            {
                logger.error("Select error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
Example #4
0
        public List <M_RegionDTO> FindByObjList(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            objList   = new List <M_RegionDTO>();
            dataTable = null;

            string procName = "sp_M_Region_FindByColumn";

            try
            {
                dataTable = new DataTable();
                adapter   = new SqlDataAdapter();
                SqlConnection conn = OpenConnection();
                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, data).ToArray());
                }
                command             = new SqlCommand(procName, conn);
                command.CommandType = CommandType.StoredProcedure;
                if (data != null)
                {
                    command.Parameters.AddRange(parameterList.ToArray());
                }



                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        obj            = new M_RegionDTO();
                        obj.RegionID   = reader["RegionID"].ToString();
                        obj.RegionCode = reader["RegionCode"].ToString();
                        obj.Name       = reader["Name"].ToString();
                        obj.Status     = reader["Status"].ToString();
                        obj.CreateDate = reader["CreateDate"].ToString();
                        obj.CreateBy   = reader["CreateBy"].ToString();
                        obj.UpdateDate = reader["UpdateDate"].ToString();
                        obj.UpdateBy   = reader["UpdateBy"].ToString();
                        objList.Add(obj);
                    }
                }
            }
            catch (Exception ex) { }
            finally
            {
                CloseConnection();
            }
            return(objList);
        }